private void fillTypeNameMap(Map<String, String> typeNameMap, TypeSystem typeSystem) { Iterator<Type> typeIterator = typeSystem.getTypeIterator(); while (typeIterator.hasNext()) { Type type = typeIterator.next(); String shortName = type.getShortName(); String name = type.getName(); typeNameMap.put(shortName, name); } }
private Type searchTypeByBaseName(String baseName) { @SuppressWarnings("unchecked") Iterator<Type> iter = Iterators.filter(ts.getTypeIterator(), Predicates.and(asList( annotationTypePredicate, typeBaseNamePredicate(baseName), namespacePredicate))); Type result = null; if (iter.hasNext()) { result = iter.next(); if (iter.hasNext()) { throw new IllegalStateException(String.format( "There are at least two types with target basename: %s, %s", result, iter.next())); } } return result; }
private Type getType(String typeName) { Type type = typeSystem.getType(typeName); if (type != null) { return type; } Iterator<Type> iterator = typeSystem.getTypeIterator(); while (iterator.hasNext()) { Type toCheck = iterator.next(); if (typeName.equals(toCheck.getShortName())) { return toCheck; } } throw new IllegalArgumentException("Unknown type: " + typeName); } }
public static void testTypeSystem(JCas jCas) throws Exception { Iterator<Type> types = jCas.getTypeSystem().getTypeIterator(); while (types.hasNext()) { try { Type type = types.next(); @SuppressWarnings("unchecked") Class<? extends TOP> cls = (Class<? extends TOP>) Class.forName(type.getName()); TOP top = cls.getConstructor(JCas.class).newInstance(jCas); testType(jCas, top); } catch (Exception e) { continue; } } } }
private Type getType(String typeName) { Type type = typeSystem.getType(typeName); if (type != null) { return type; } Iterator<Type> iterator = typeSystem.getTypeIterator(); while (iterator.hasNext()) { Type toCheck = iterator.next(); if (typeName.equals(toCheck.getShortName())) { return toCheck; } } throw new IllegalArgumentException("Unknown type: " + typeName); } }
private Type getClassType(Class<? extends Annotation> cls) { for(Type type:Lists.newArrayList(actual.getTypeSystem().getTypeIterator())) { if(type.getName().equals(cls.getName())) return type; } throw new IllegalArgumentException("No type found for class: " + cls.getName()); }
private Type getType(String annotationType) { for(Type type:Lists.newArrayList(actual.getTypeSystem().getTypeIterator())) { if(type.getName().equals(annotationType)) return type; else if(type.getShortName().equals(annotationType)) return type; } throw new IllegalArgumentException("No such type found: " + annotationType); }
if (type == null) { StringBuilder sb = new StringBuilder(); Iterator<Type> i = aCas.getTypeSystem().getTypeIterator(); while (i.hasNext()) { sb.append(i.next().getName()).append('\n');
/** * Import all packages that are imported by the script. * * @param casTS * Type system containing all known types. */ private void importPackageAliases(TypeSystem casTS) { Iterator<Type> iter = casTS.getTypeIterator(); while (iter.hasNext()) { Type type = iter.next(); String name = type.getName(); String pkg = name.substring(0, Math.max(name.lastIndexOf('.'), 0)); List<String> aliases = packageImports.get(pkg); if (aliases != null) { for (String alias : aliases) { if (alias.isEmpty()) { addType(type); } else { addType(alias + "." + type.getShortName(), type); } } } } }
/** * Update. */ // create a hash table of all types private void update() { cachedResult.clear(); CAS tcas = modelRoot.getCurrentView(); if (null == tcas) return; TypeSystem typeSystem = tcas.getTypeSystem(); if (typeSystem == null) return; Iterator typeIterator = typeSystem.getTypeIterator(); while (typeIterator.hasNext()) { Type type = (Type) typeIterator.next(); String typeName = type.getName(); if (null != typeName && !typeName.endsWith("[]")) { cachedResult.put(type.getName(), type); } } } }
String layerName = layerTk.nextToken().trim(); Iterator<Type> types = aJcas.getTypeSystem().getTypeIterator(); boolean layerExists = false; while (types.hasNext()) {
String layerName = layerTk.nextToken().trim(); Iterator<Type> types = aJcas.getTypeSystem().getTypeIterator(); boolean layerExists = false; while (types.hasNext()) {
String layerName = layerTk.nextToken().trim(); Iterator<Type> types = aJcas.getTypeSystem().getTypeIterator(); boolean layerExists = false; while (types.hasNext()) {
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
/** * Convert a {@link TypeSystem} to an equivalent {@link TypeSystemDescription}. * * @param aTypeSystem * type system object to convert * @return a TypeSystemDescription that is equivalent to <code>aTypeSystem</code> */ public static TypeSystemDescription typeSystem2TypeSystemDescription(TypeSystem aTypeSystem) { ResourceSpecifierFactory fact = UIMAFramework.getResourceSpecifierFactory(); TypeSystemDescription tsDesc = fact.createTypeSystemDescription(); Iterator<Type> typeIter = aTypeSystem.getTypeIterator(); ArrayList<TypeDescription> typeDescs = new ArrayList<TypeDescription>(); while (typeIter.hasNext()) { Type type = typeIter.next(); if (!type.getName().startsWith("uima.cas") && !type.getName().equals("uima.tcas.Annotation") && !type.isArray()) { typeDescs.add(type2TypeDescription(type, aTypeSystem)); } } TypeDescription[] typeDescArr = new TypeDescription[typeDescs.size()]; typeDescs.toArray(typeDescArr); tsDesc.setTypes(typeDescArr); return tsDesc; }
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
private void copyDownSuperGenerators(Map<String, LoadedJCasType<?>> jcasTypes, FSGenerator<?>[] fsGenerators) { final TypeSystem ts = casImpl.getTypeSystem(); Iterator<Type> typeIt = ts.getTypeIterator(); // reset iterator to start Type topType = ts.getTopType(); Type superType = null;
Iterator<Type> it = ts.getTypeIterator();
Iterator<Type> it = ts.getTypeIterator();