本文整理匯總了Java中org.scijava.annotations.Index類的典型用法代碼示例。如果您正苦於以下問題:Java Index類的具體用法?Java Index怎麽用?Java Index使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Index類屬於org.scijava.annotations包,在下文中一共展示了Index類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildElementReaderIndex
import org.scijava.annotations.Index; //導入依賴的package包/類
/** Set-up the {@link ElementReader} index */
private void buildElementReaderIndex() {
elementReaderIndex = new ArrayList<ReaderRecord>();
for(IndexItem<ElementReaderMetadata> item :
Index.load(ElementReaderMetadata.class, getClass().getClassLoader())) {
ElementReaderMetadata a = item.annotation();
try {
ReaderRecord r = new ReaderRecord(
item.className(),
a.name(),
a.processedType(),
a.elementType(),
a.mimeTypes(),
a.hidden());
elementReaderIndex.add(r);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
}
示例2: buildElementWriterIndex
import org.scijava.annotations.Index; //導入依賴的package包/類
/** Set-up the {@link ElementWriter} index */
private void buildElementWriterIndex() {
elementWriterIndex = new ArrayList<WriterRecord>();
for(IndexItem<ElementWriterMetadata> item :
Index.load(ElementWriterMetadata.class, getClass().getClassLoader())) {
ElementWriterMetadata a = item.annotation();
try {
WriterRecord r = new WriterRecord(
item.className(),
a.name(),
a.processedType(),
a.elementType(),
a.mimeType(),
a.linkExt());
if(r.mimeType.equals("null"))
r.mimeType = null;
if(r.linkExt.equals("null"))
r.linkExt = null;
elementWriterIndex.add(r);
} catch(ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
}
示例3: buildTypeAliasIndex
import org.scijava.annotations.Index; //導入依賴的package包/類
/** Set-up the {@link TypeAlias} index */
private void buildTypeAliasIndex() {
typeAliasIndex = new
LinkedHashMap<Class<?>, Class<? extends TypeAlias>>();
for(IndexItem<TypeAliasMetadata> item :
Index.load(TypeAliasMetadata.class, getClass().getClassLoader())) {
try {
TypeAlias ta = (TypeAlias) Class.forName(
item.className()).newInstance();
typeAliasIndex.put(
ta.getRealType(),
ta.getClass());
} catch (Exception e) {
throw new IllegalStateException(
"Couldn't load type aliases: ", e);
}
}
}
示例4: build
import org.scijava.annotations.Index; //導入依賴的package包/類
private static void build()
{
buildWasCalled = true;
try
{
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final Index< ViewSetupAttributeIo > annotationIndex = Index.load( ViewSetupAttributeIo.class, classLoader );
for ( final IndexItem< ViewSetupAttributeIo > item : annotationIndex )
{
name_to_XmlIoClassName.put( item.annotation().name(), item.className() );
attributeClass_to_name.put( item.annotation().type(), item.annotation().name() );
}
}
catch( final Exception e )
{
throw new RuntimeException( "problem accessing annotation index", e );
}
}
示例5: build
import org.scijava.annotations.Index; //導入依賴的package包/類
private static void build()
{
buildWasCalled = true;
try
{
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final Index< ImgLoaderIo > annotationIndex = Index.load( ImgLoaderIo.class, classLoader );
for ( final IndexItem< ImgLoaderIo > item : annotationIndex )
{
format_to_XmlIoClassName.put( item.annotation().format(), item.className() );
imgLoaderClass_to_XmlIoClassName.put( item.annotation().type(), item.className() );
}
}
catch( final Exception e )
{
throw new RuntimeException( "problem accessing annotation index", e );
}
}
示例6: update
import org.scijava.annotations.Index; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void update() {
compressionParameters.clear();
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final Index<CompressionType> annotationIndex = Index.load(CompressionType.class, classLoader);
for (final IndexItem<CompressionType> item : annotationIndex) {
Class<? extends Compression> clazz;
try {
clazz = (Class<? extends Compression>)Class.forName(item.className());
final String type = clazz.getAnnotation(CompressionType.class).value();
Constructor<? extends Compression> constructor = clazz.getDeclaredConstructor();
final HashMap<String, Class<?>> parameters = new HashMap<>();
ArrayList<Field> fields = getDeclaredFields(clazz);
for (final Field field : fields) {
if (field.getAnnotation(CompressionParameter.class) != null) {
parameters.put(field.getName(), field.getType());
}
}
compressionConstructors.put(type, constructor);
compressionParameters.put(type, parameters);
} catch (final ClassNotFoundException | NoSuchMethodException | ClassCastException e) {
e.printStackTrace();
}
}
}