Java源码示例:org.glassfish.jersey.server.internal.LocalizationMessages

示例1
/**
 * <p>getClassForName.</p>
 *
 * @param className a {@link java.lang.String} object.
 * @return a {@link java.lang.Class} object.
 */
public Class getClassForName(final String className) {
    try {
        final OsgiRegistry osgiRegistry = ReflectionHelper.getOsgiRegistryInstance();

        if (osgiRegistry != null) {
            return osgiRegistry.classForNameWithException(className);
        } else {
            return AccessController.doPrivileged(ReflectionHelper.classForNameWithExceptionPEA(className));
        }
    } catch (final ClassNotFoundException ex) {
        throw new RuntimeException(LocalizationMessages.ERROR_SCANNING_CLASS_NOT_FOUND(className), ex);
    } catch (final PrivilegedActionException pae) {
        final Throwable cause = pae.getCause();
        if (cause instanceof ClassNotFoundException) {
            throw new RuntimeException(LocalizationMessages.ERROR_SCANNING_CLASS_NOT_FOUND(className), cause);
        } else if (cause instanceof RuntimeException) {
            throw (RuntimeException) cause;
        } else {
            throw new RuntimeException(cause);
        }
    }
}
 
示例2
/**
 * Uses {@link AsyncContext} to suspend current request
 *
 * @return obtained {@link AsyncContext} or throws error
 */
protected AsyncContext suspend() {
    final AsyncContext asyncContext = asyncContextProvider.get();

    if (!asyncContext.suspend()) {
        throw new ProcessingException(LocalizationMessages.ERROR_SUSPENDING_ASYNC_REQUEST());
    }

    return asyncContext;
}
 
示例3
@Override
public Duration fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return Duration.parse(value);
}
 
示例4
@Override
public String toString(Duration value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}
 
示例5
@Override
public Period fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return Period.parse(value);
}
 
示例6
@Override
public String toString(Period value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}
 
示例7
@Override
public Instant fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return parseInstant(value);
}
 
示例8
@Override
public String toString(Instant value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}
 
示例9
@Override
public LocalDate fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }

    return LocalDate.from(parseInstant(value));
}
 
示例10
@Override
public String toString(LocalDate value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}
 
示例11
@Override
public LocalDateTime fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return LocalDateTime.from(parseInstant(value));
}
 
示例12
@Override
public String toString(LocalDateTime value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}
 
示例13
@Override
public LocalTime fromString(String value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return LocalTime.from(parseInstant(value));
}
 
示例14
@Override
public String toString(LocalTime value) {
    if (value == null) {
        throw new IllegalArgumentException(
                LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
        );
    }
    return value.toString();
}