本文整理了Java中org.geotools.resources.Utilities.getShortName()
方法的一些代码示例,展示了Utilities.getShortName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getShortName()
方法的具体详情如下:
包路径:org.geotools.resources.Utilities
类名称:Utilities
方法名:getShortName
[英]Returns a short class name for the specified class. This method will omit the package name. For example, it will return "String" instead of "java.lang.String" for a String object. It will also name array according Java language usage, for example "double[]" instead of "[D".
[中]返回指定类的短类名。此方法将省略包名。例如,对于字符串对象,它将返回“String”而不是“java.lang.String”。它还将根据Java语言使用情况命名数组,例如“double[]”而不是“[D”。
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Constructs an exception with an error message formatted for the specified class.
*
* @param classe The unexpected implementation class.
*/
public UnsupportedImplementationException(final Class classe) {
// TODO: Provides a localized message.
super(Utilities.getShortName(classe));
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Returns a short class name for the specified object. This method will
* omit the package name. For example, it will return "String" instead
* of "java.lang.String" for a {@link String} object.
*
* @param object The object (may be {@code null}).
* @return A short class name for the specified object.
*/
public static String getShortClassName(final Object object) {
return getShortName(object!=null ? object.getClass() : null);
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Returns the rank (in the {@link #CLASS_RANK} array) of the specified class.
*/
private static int getRank(final Class c) {
for (int i=0; i<CLASS_RANK.length; i++) {
if (CLASS_RANK[i].isAssignableFrom(c)) {
return i;
}
}
throw new IllegalArgumentException(Utilities.getShortName(c));
}
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Constructs an exception with an error message formatted for the specified class
* and a cause.
*
* @param classe The unexpected implementation class.
* @param cause The cause for the exception.
*/
public UnsupportedImplementationException(final Class classe, final Exception cause) {
// TODO: Provides a localized message.
super(Utilities.getShortName(classe));
initCause(cause); // TODO: use the constructor with cause arg. in J2E 1.5.
}
}
代码示例来源:origin: org.geotools/gt2-main
/**
* Format an error message saying that the specified factory is not yet supported.
* The error message will be given to a {@link FactoryNotFoundException}.
*
* @param type The factory type requested by the users.
*/
private static String unsupportedFactory(final Class type) {
return Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, Utilities.getShortName(type));
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Creates a new exception with a default message determined from the specified category.
*/
public RecursiveSearchException(final Class category) {
super(Errors.format(ErrorKeys.RECURSIVE_CALL_$1, Utilities.getShortName(category)));
}
代码示例来源:origin: org.geotools/gt2-coverage
/**
* Returns a localized error message for the specified array.
*/
private static String formatErrorMessage(final Object array) {
String text = "<null>";
if (array != null) {
Class type = array.getClass();
if (type.isArray()) {
type = type.getComponentType();
}
text = Utilities.getShortName(type);
}
return Errors.format(ErrorKeys.CANT_CONVERT_FROM_TYPE_$1, text);
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Converts a wrapper class to a primitive class. For example this method converts
* <code>{@linkplain Double}.class</code> to <code>Double.{@linkplain Double#TYPE TYPE}</code>.
*
* @param c The wrapper class.
* @return The primitive class.
* @throws IllegalArgumentException if the specified class is not a wrapper for a primitive.
*/
public static Class toPrimitive(final Class c) throws IllegalArgumentException {
if (Double .class.equals(c)) return Double .TYPE;
if (Float .class.equals(c)) return Float .TYPE;
if (Long .class.equals(c)) return Long .TYPE;
if (Integer .class.equals(c)) return Integer .TYPE;
if (Short .class.equals(c)) return Short .TYPE;
if (Byte .class.equals(c)) return Byte .TYPE;
if (Boolean .class.equals(c)) return Boolean .TYPE;
if (Character.class.equals(c)) return Character.TYPE;
throw new IllegalArgumentException(Utilities.getShortName(c));
}
代码示例来源:origin: org.geotools/gt2-coverage
/**
* Returns the interpolation name for the specified interpolation object.
* This method tries to infer the name from the object's class name.
*
* @param Interpolation The interpolation object.
*/
public static String getInterpolationName(final Interpolation interp) {
final String prefix = "Interpolation";
for (Class classe = interp.getClass(); classe!=null; classe=classe.getSuperclass()) {
String name = Utilities.getShortName(classe);
int index = name.lastIndexOf(prefix);
if (index >= 0) {
return name.substring(index + prefix.length());
}
}
return Utilities.getShortClassName(interp);
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Converts a primitive class to a wrapper class. For example this method converts
* <code>Double.{@linkplain Double#TYPE TYPE}</code> to <code>{@linkplain Double}.class</code>.
*
* @param c The primitive class.
* @return The wrapper class.
* @throws IllegalArgumentException if the specified class is not a primitive.
*/
public static Class toWrapper(final Class c) throws IllegalArgumentException {
if (Double .TYPE.equals(c)) return Double .class;
if (Float .TYPE.equals(c)) return Float .class;
if (Long .TYPE.equals(c)) return Long .class;
if (Integer .TYPE.equals(c)) return Integer .class;
if (Short .TYPE.equals(c)) return Short .class;
if (Byte .TYPE.equals(c)) return Byte .class;
if (Boolean .TYPE.equals(c)) return Boolean .class;
if (Character.TYPE.equals(c)) return Character.class;
throw new IllegalArgumentException(Utilities.getShortName(c));
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Casts the number to the specified class. The class must by one of {@link Byte},
* {@link Short}, {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
*
* @todo Use {@code valueOf} when we will be allowed to compile for J2SE 1.5.
*/
public static Number cast(final Number n, final Class c) {
if (n!=null && !n.getClass().equals(c)) {
if (Byte .class.equals(c)) return new Byte (n. byteValue());
if (Short .class.equals(c)) return new Short (n. shortValue());
if (Integer.class.equals(c)) return new Integer(n. intValue());
if (Long .class.equals(c)) return new Long (n. longValue());
if (Float .class.equals(c)) return new Float (n. floatValue());
if (Double .class.equals(c)) return new Double (n.doubleValue());
throw new IllegalArgumentException(Utilities.getShortName(c));
}
return n;
}
代码示例来源:origin: org.geotools/gt2-coverageio
/**
* Returns the pattern used for parsing and formatting values of the specified type.
* The type should be either {@code Number.class} or {@code Date.class}.
* <p>
* <ul>
* <li>if {@code type} is assignable to {@code Number.class}, then this method
* returns the number pattern as specified by {@link DecimalFormat}.</li>
* <li>Otherwise, if {@code type} is assignable to {@code Date.class}, then this method
* returns the date pattern as specified by {@link SimpleDateFormat}.</li>
* </ul>
* <p>
* In any case, this method returns {@code null} if this object should use the default
* pattern for the {@linkplain #getLocale data locale}.
*
* @param type The data type ({@code Number.class} or {@code Date.class}).
* @return The format pattern for the specified data type, or {@code null} for
* the default locale-dependent pattern.
* @throws IllegalArgumentException if {@code type} is not valid.
*/
public String getFormatPattern(final Class type) {
if (Date.class.isAssignableFrom(type)) {
return datePattern;
}
if (Number.class.isAssignableFrom(type)) {
return numberPattern;
}
throw new IllegalArgumentException(Utilities.getShortName(type));
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Checks the type of the specified object. The default implementation ensure
* that the object is assignable to the type specified at construction time.
*
* @param element the object to check, or {@code null}.
* @throws IllegalArgumentException if the specified element is not of the expected type.
*/
protected void ensureValidType(final Object element) throws IllegalArgumentException {
if (element!=null && !type.isInstance(element)) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_CLASS_$2,
Utilities.getShortClassName(element), Utilities.getShortName(type)));
}
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Prepares a message to be logged if any provider has been registered.
*/
private static StringBuffer getLogHeader(final Class category) {
return new StringBuffer(Logging.getResources(null).getString(
LoggingKeys.FACTORY_IMPLEMENTATIONS_$1, Utilities.getShortName(category)));
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Checks the type of the specified object. The default implementation ensure
* that the object is assignable to the type specified at construction time.
*
* @param element the object to check, or {@code null}.
* @throws IllegalArgumentException if the specified element is not of the expected type.
*/
protected void ensureValidType(final Object element) throws IllegalArgumentException {
if (element!=null && !type.isInstance(element)) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_CLASS_$2,
Utilities.getShortClassName(element), Utilities.getShortName(type)));
}
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Invoked when a factory can't be loaded. Log a warning, but do not stop the process.
*/
private static void loadingFailure(final Class category, final Throwable error,
final boolean showStackTrace)
{
final String name = Utilities.getShortName(category);
final StringBuffer cause = new StringBuffer(Utilities.getShortClassName(error));
final String message = error.getLocalizedMessage();
if (message != null) {
cause.append(": ");
cause.append(message);
}
final LogRecord record = Logging.format(Level.WARNING,
LoggingKeys.CANT_LOAD_SERVICE_$2, name, cause.toString());
if (showStackTrace) {
record.setThrown(error);
}
record.setSourceClassName(FactoryRegistry.class.getName());
record.setSourceMethodName("scanForPlugins");
LOGGER.log(record);
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Checks the type of the specified object. The default implementation ensure
* that the object is assignable to the type specified at construction time.
*
* @param element the object to check, or {@code null}.
* @throws IllegalArgumentException if the specified element is not of the expected type.
*/
private static void ensureValidType(final Object element, final Class type)
throws IllegalArgumentException
{
if (element!=null && !type.isInstance(element)) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_CLASS_$2,
Utilities.getShortClassName(element), Utilities.getShortName(type)));
}
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Creates a tree for the specified metadata.
*/
public MutableTreeNode asTree(final Object metadata) {
final String name = Utilities.getShortName(standard.getInterface(metadata.getClass()));
final DefaultMutableTreeNode root =
OptionalDependencies.createTreeNode(localize(name), metadata, true);
append(root, metadata);
return root;
}
代码示例来源:origin: org.geotools/gt2-widgets-swing
/**
* Show this component. This method is used mostly in order
* to check the look of this widget from the command line.
*/
public static void main(final String[] args) {
final Arguments arguments = new Arguments(args);
Locale.setDefault(arguments.locale);
new FormatChooser(new AngleFormat())
.showDialog(null, Utilities.getShortName(FormatChooser.class));
System.exit(0);
}
}
代码示例来源:origin: org.geotools/gt2-widgets-swing
/**
* Set the type and the range of valid values.
*/
public void setValueRange(Class classe, final Range range) {
String type = null;
String minimum = null;
String maximum = null;
if (classe != null) {
while (classe.isArray()) {
classe = classe.getComponentType();
}
classe = XMath.primitiveToWrapper(classe);
boolean isInteger = false;
if (XMath.isReal(classe) || (isInteger=XMath.isInteger(classe))==true) {
type = Vocabulary.format(isInteger ? VocabularyKeys.SIGNED_INTEGER_$1
: VocabularyKeys.REAL_NUMBER_$1,
new Integer(XMath.getBitCount(classe)));
} else {
type = Utilities.getShortName(classe);
}
}
if (range != null) {
minimum = format(range.getMinValue());
maximum = format(range.getMaxValue());
}
this.type .setText(type);
this.minimum.setText(minimum);
this.maximum.setText(maximum);
}
内容来源于网络,如有侵权,请联系作者删除!