/** * Creates an AnnotationReferenceDataType with a given id. * * @param aType the annotation type that AnnotationRefs shall refer to. * @param id the id to use */ public AnnotationReferenceDataType(AnnotationType aType, int id) { super("annotationreference<" + ((aType == null) ? "" : aType.getName()) + ">", id); this.aType = aType; }
/** * Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param id the id of the type to unregister. * @return true if the type was successfully unregistered, false otherwise (it was not present) */ public boolean unregister(int id) { AnnotationType oldType = idMap.remove(id); if (oldType != null) { nameMap.remove(oldType.getName()); return true; } return false; }
/** * Creates an AnnotationReferenceDataType with a generated id. * * @param aType the annotation type that AnnotationRefs shall refer to. */ public AnnotationReferenceDataType(AnnotationType aType) { super("annotationreference<" + ((aType == null) ? "" : aType.getName()) + ">", 0); setAnnotationType(aType); }
/** * Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the AnnotationType to unregister. * @return true if the type was successfully unregistered, false otherwise (it was not present) * @throws IllegalArgumentException if the ID and name of this annotation type are present, but they do not belong together. */ public boolean unregister(AnnotationType type) { if (idMap.containsKey(type.getId()) && nameMap.containsKey(type.getName())) { AnnotationType idType = idMap.get(type.getId()); AnnotationType nameType = nameMap.get(type.getName()); if (idType == nameType) { //name and id belong together in our maps idMap.remove(type.getId()); nameMap.remove(type.getName()); } else { throw new IllegalArgumentException("The ID and name of this annotation type are present, but they do not belong together. Not removing type."); } return true; } //it's not there, but that's no problem return false; }
/** * Register a new annotation type. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the type to register * @throws IllegalArgumentException if a type is already registered with this name or this id, and it is non-equal to the argument. */ public void register(AnnotationType type) { if (idMap.containsKey(type.getId()) || nameMap.containsKey(type.getName())) { AnnotationType idType = idMap.get(type.getId()); AnnotationType nameType = nameMap.get(type.getName()); if (type.equals(idType) && type.equals(nameType)) { //it's the same one being re-registered, we're OK! return; } throw new IllegalArgumentException("A type is already registered with this name or this id."); } idMap.put(type.getId(), type); nameMap.put(type.getName(), type); }
@Override public void setAnnotationType(AnnotationType type) { super.setName("annotationreference<" + type.getName() + ">"); super.setAnnotationType(type); } }
private void buildConfig(AnnotationType type, DocumentmanagerConfig.Annotationtype.Builder atb) { atb. id(type.getId()). name(type.getName()); if (type.getDataType() != null) { atb.datatype(type.getDataType().getId()); } if ( ! type.getInheritedTypes().isEmpty()) { for (AnnotationType inherited : type.getInheritedTypes()) { atb.inherits(new DocumentmanagerConfig.Annotationtype.Inherits.Builder().id(inherited.getId())); } } } private void buildConfig(Collection<AnnotationType> types, DocumentmanagerConfig.Builder builder) {
private void buildConfig(AnnotationType annotation, DocumenttypesConfig.Documenttype.Annotationtype.Builder builder) { builder. id(annotation.getId()). name(annotation.getName()); DataType dt = annotation.getDataType(); if (dt != null) { builder.datatype(dt.getId()); } for (AnnotationType inherited : annotation.getInheritedTypes()) { builder.inherits(new DocumenttypesConfig.Documenttype.Annotationtype.Inherits.Builder().id(inherited.getId())); } }
StructDataType s = new StructDataType("annotation."+annotation.getName()); if (anyParentsHavePayLoad(sa, sdoc)) { annotation.setDataType(s);
builder.annotationreftype(new Datatype.Annotationreftype.Builder().annotation(annotationRef.getAnnotationType().getName())); } else if (type instanceof TensorDataType) {