本文整理汇总了Java中org.scijava.annotations.Index.load方法的典型用法代码示例。如果您正苦于以下问题:Java Index.load方法的具体用法?Java Index.load怎么用?Java Index.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.scijava.annotations.Index
的用法示例。
在下文中一共展示了Index.load方法的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();
}
}
}