public Pod(@Attribute(name = "error") final boolean error, @Attribute(name = "primary") final boolean primary, @Attribute(name = "title") final String title, @Attribute(name = "scanner") final String scanner, @Attribute(name = "id") final String id, @Attribute(name = "position") final long position, @Attribute(name = "numsubpods") final long numsubpods, @ElementList(inline = true, name = "subpods") final List<SubPod> subpods, @Element(name = "states") final States states, @Element(name = "infos") final Infos infos, @Element(name = "definitions", required = false) final Definitions definitions) { this.error = error; this.title = title; this.scanner = scanner; this.id = id; this.position = position; this.numsubpods = numsubpods; this.subpods = subpods; this.primary = primary; this.states = states; this.infos = infos; this.definitions = definitions; }
public void testMixedAnnotationsWithNoDefaults() throws Exception { Map<String, Contact> map = getContacts(MixedAnnotations.class); assertEquals(map.size(), 4); assertFalse(map.get("name").isReadOnly()); assertFalse(map.get("value").isReadOnly()); assertEquals(int.class, map.get("value").getType()); assertEquals(String.class, map.get("name").getType()); assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType()); assertEquals(Element.class, map.get("value").getAnnotation().annotationType()); assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType()); assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType()); assertNull(map.get("name").getAnnotation(Root.class)); assertNull(map.get("value").getAnnotation(Root.class)); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * Konstruktor nur f�r das Laden der XML Dateien. Da m�ssen alle Angaben * gemacht werden, die in der XML gespeichert sind. * * @param id * @param valid * @param stimmen * @param commited */ public Wahlzettel(@Attribute(name = "id") int id, @Attribute(name = "valid") boolean valid, @ElementList(name = "stimmen") ArrayList<Stimme> stimmen, @Attribute(name = "commited") int commited, @Attribute(name = "party") int party) { this.id = id; this.rc = new RegelChecker(); this.stimmen = stimmen; this.valid = valid; this.commited = commited; this.party=party; //sortieren: Collections.sort(stimmen); }
public Alternative(@Attribute(name = "level", required = false) final String level, @Attribute(name = "score", required = false) final double score, @Text final String text) { this.level = level; this.score = score; this.text = text; }
public StateList(@Attribute(name = "count") final long count, @Attribute(name = "delimiters", required = false) final String delimiters, @ElementList(inline = true, name = "state") final List<State> state, @Attribute(name = "value", required = false) final String value) { this.count = count; this.delimiters = delimiters; this.state = state; this.value = value; }
public States(@Attribute(name = "count") final long count, @ElementList(inline = true, name = "state") final List<State> state, @Element(name = "statelist", required = false) final StateList stateList) { this.count = count; this.state = state; this.stateList = stateList; }
public Assumption(@Attribute(name = "count") final long count, @Attribute(name = "template", required = false) final String template, @Attribute(name = "type") final String type, @ElementList(inline = true, name = "value") final List<Value> values, @Attribute(name = "word", required = false) final String word, @Attribute(name = "current", required = false) final long current, @Attribute(name = "desc", required = false) final String desc) { this.count = count; this.template = template; this.type = type; this.values = values; this.word = word; this.current = current; this.desc = desc; }
public SubPod(@Element(name = "plaintext") final String plaintext, @Attribute(name = "title") final String title, @Element(name = "imagesource", required = false) final String imagesource) { this.plaintext = plaintext; this.title = title; this.imagesource = imagesource; }
public SpellCheck(@Attribute(name = "suggestion") final String suggestion, @Attribute(name = "text") final String text, @Attribute(name = "word") final String word) { this.suggestion = suggestion; this.text = text; this.word = word; }
public Warnings(@Attribute(name = "count") final long count, @Element(name = "reinterpret", required = false) final Reinterpret reinterpret, @Element(name = "spellcheck", required = false) final SpellCheck spellcheck) { this.count = count; this.reinterpret = reinterpret; this.spellcheck = spellcheck; }
public Reinterpret(@Attribute(name = "level", required = false) final String level, @Attribute(name = "new", required = false) final String replaced, @Attribute(name = "score", required = false) final double score, @Attribute(name = "text", required = false) final String text, @ElementList(inline = true, name = "alternative", required = false) final List<Alternative> alternatives) { this.level = level; this.replaced = replaced; this.score = score; this.text = text; this.alternatives = alternatives; }
public OObject(@Attribute(required = true, name = "O_id") String O_id, @Element(required = true, name = "C") Type C, IDomain parent) { super(); this.O_id = O_id; this.C = C; // parent is the parent domain of this this.parent = parent; // NOTE: would be hackish to do the following: // parentDomain.addObject(this); }
public ODFEdge(@Element(required = true, name = "osrc") OObject osrc, @Element(required = true, name = "odst") OObject odst, @Element(required = true, name = "flow") OObject flow, @Attribute(required = true, name = "flag") EdgeFlag flag) { super(osrc, odst); this.flow = flow; this.flag = flag; }
public ODFEdge(@Element(required = true, name = "osrc") OObject osrc, @Element(required = true, name = "odst") OObject odst, @Element(required = true, name = "flow") OObject flow, @Attribute(required = true, name = "flag") EdgeFlag flag, @Attribute(required = false, name = "hasFlow") boolean hasFlow, @Attribute(required = false, name = "flowType")String flowType ) { this(osrc, odst, flow, flag); this.hasFlow = hasFlow; this.flowType = flowType; }
/** * Use this constructor when loading from file * @param srcObject * @param dstDomain */ public RenameDomain(@Attribute(name = "srcObject") String srcObject, @Attribute(name = "oldDomainName") String oldDomainName, @Attribute(name = "newDomainName") String newDomainName) { super(); this.srcObject = srcObject; this.oldDomainName = oldDomainName; this.newDomainName = newDomainName; }
/** * Use this constructor when reviving objects from persistence * @param srcObj * @param dstObj * @param dstDomain */ public Refinement(@Attribute(name = "srcObject")String srcObj, @Attribute(name = "dstObject")String dstObj, @Attribute(name = "dstDomain") String dstDomain) { this.srcObject = srcObj; this.dstObject = dstObj; this.dstDomain = dstDomain; }
/** * Use this constructor when loading from file * @param srcObject * @param dstDomain */ public CreateDomain(@Attribute(name = "srcObject") String srcObject, @Attribute(name = "dstDomain") String dstDomain) { super(); this.srcObject = srcObject; this.dstDomain = dstDomain; }
/** * Use this constructor when reviving objects from persistence * @param srcObj * @param dstObj * @param dstDomain */ public Heuristic(@Attribute(name = "srcObject")String srcObj, @Attribute(name = "dstObject")String dstObj, @Attribute(name = "dstDomain") String dstDomain) { this.srcObject = srcObj; this.dstObject = dstObj; this.dstDomain = dstDomain; }
/** * For most uses, use the factory method * Used by persistence code. */ // TODO: HIGH. Make private once factory method is working public Type(@Attribute(required = true, name = "fullyQualifiedName") String fullyQualifiedName) { // Call default constructor, which does additional work this(); this.fullyQualifiedName = fullyQualifiedName; // Add to the map // TODO: HIGH. Not sure we need to populate both the TypeInfo and the TypeAdapter! TypeAdapter typeAdapter = TypeAdapter.getInstance(); typeAdapter.addType(this); }
/** * This is used to create <code>Parameter</code> objects which are * used to represent the parameters in a constructor. Each parameter * contains an annotation an the index it appears in. * * @param label this is the annotation used for the parameter * @param ordinal this is the position the parameter appears at * * @return this returns the parameters for the constructor */ private List<Parameter> process(Annotation label, int ordinal) throws Exception{ if(label instanceof Attribute) { return create(label, ordinal); } if(label instanceof Element) { return create(label, ordinal); } if(label instanceof ElementList) { return create(label, ordinal); } if(label instanceof ElementArray) { return create(label, ordinal); } if(label instanceof ElementMap) { return create(label, ordinal); } if(label instanceof ElementListUnion) { return union(label, ordinal); } if(label instanceof ElementMapUnion) { return union(label, ordinal); } if(label instanceof ElementUnion) { return union(label, ordinal); } if(label instanceof Text) { return create(label, ordinal); } return emptyList(); }
/** * Creates an entry that is used to select the constructor for the * parameter. Each parameter must implement a constructor that takes * a constructor, and annotation, and the index of the parameter. If * the annotation is not know this method throws an exception. * * @param label the XML annotation used to create the parameter * * @return this returns the entry used to create a constructor */ private ParameterBuilder getBuilder(Annotation label) throws Exception{ if(label instanceof Element) { return new ParameterBuilder(ElementParameter.class, Element.class); } if(label instanceof ElementList) { return new ParameterBuilder(ElementListParameter.class, ElementList.class); } if(label instanceof ElementArray) { return new ParameterBuilder(ElementArrayParameter.class, ElementArray.class); } if(label instanceof ElementMapUnion) { return new ParameterBuilder(ElementMapUnionParameter.class, ElementMapUnion.class, ElementMap.class); } if(label instanceof ElementListUnion) { return new ParameterBuilder(ElementListUnionParameter.class, ElementListUnion.class, ElementList.class); } if(label instanceof ElementUnion) { return new ParameterBuilder(ElementUnionParameter.class, ElementUnion.class, Element.class); } if(label instanceof ElementMap) { return new ParameterBuilder(ElementMapParameter.class, ElementMap.class); } if(label instanceof Attribute) { return new ParameterBuilder(AttributeParameter.class, Attribute.class); } if(label instanceof Text) { return new ParameterBuilder(TextParameter.class, Text.class); } throw new PersistenceException("Annotation %s not supported", label); }
/** * Creates an entry that is used to select the constructor for the * label. Each label must implement a constructor that takes a * contact and the specific XML annotation for that field. If the * annotation is not know this method throws an exception. * * @param label the XML annotation used to create the label * * @return this returns the entry used to create a constructor */ private LabelBuilder getBuilder(Annotation label) throws Exception{ if(label instanceof Element) { return new LabelBuilder(ElementLabel.class, Element.class); } if(label instanceof ElementList) { return new LabelBuilder(ElementListLabel.class, ElementList.class); } if(label instanceof ElementArray) { return new LabelBuilder(ElementArrayLabel.class, ElementArray.class); } if(label instanceof ElementMap) { return new LabelBuilder(ElementMapLabel.class, ElementMap.class); } if(label instanceof ElementUnion) { return new LabelBuilder(ElementUnionLabel.class, ElementUnion.class, Element.class); } if(label instanceof ElementListUnion) { return new LabelBuilder(ElementListUnionLabel.class, ElementListUnion.class, ElementList.class); } if(label instanceof ElementMapUnion) { return new LabelBuilder(ElementMapUnionLabel.class, ElementMapUnion.class, ElementMap.class); } if(label instanceof Attribute) { return new LabelBuilder(AttributeLabel.class, Attribute.class); } if(label instanceof Version) { return new LabelBuilder(VersionLabel.class, Version.class); } if(label instanceof Text) { return new LabelBuilder(TextLabel.class, Text.class); } throw new PersistenceException("Annotation %s not supported", label); }
public NestedElementExample( @Element(name="city") String city, @Element(name="street") String street, @Element(name="mobile") String mobile, @Element(name="home") String home, @Attribute(name="area-code") int areaCode) { this.city=city; this.street=street; this.mobile=mobile; this.home=home; this.areaCode = areaCode; }
@Attribute(required = false) public Long getPriorityId() { if (getDelegated().getPriority() != null) return getDelegated().getPriority().getId(); return null; }
@Attribute(required = false) public void setPriorityId(Long priorityId) { if (isItemSelected(priorityId)) getDelegated().setPriority(new CasePriority(priorityId)); else getDelegated().setPriority(null); }
@Attribute(required = false) public Long getCategoryId() { if (getDelegated().getCategory() != null) return getDelegated().getCategory().getId(); return null; }
@Attribute(required = false) public void setCategoryId(Long categoryId) { if (isItemSelected(categoryId)) getDelegated().setCategory(new Category(categoryId)); else getDelegated().setCategory(null); }
@Attribute(required = false) public Long getStatusId() { if (getDelegated().getStatus() != null) return getDelegated().getStatus().getId(); return null; }
@Attribute(required = false) public void setStatusId(Long statusId) { if (isItemSelected(statusId)) getDelegated().setStatus(new CaseStatus(statusId)); else getDelegated().setStatus(null); }
public Example( @Attribute(name="name") String name, @Element(name="value") String value, @Attribute(name="type") Integer type) { this.name = name; this.value = value; this.type = type; }
@Attribute(required = true) public Long getTestPlanId() { if (getDelegated().getTestPlan() != null) return getDelegated().getTestPlan().getId(); return null; }
private PathWithTextAndElementExample( @Text String text, @Path("some/path") @Attribute(name="name") String value, @Path("some") @Element(name="name") String item) { this.item = item; this.value = value; this.text = text; }
/** * This reflectively checks the annotation to determine the type * of annotation it represents. If it represents an XML schema * annotation it is used to create a <code>Contact</code> which * can be used to represent the method within the source object. * * @param method the method that the annotation comes from * @param label the annotation used to model the XML schema * @param list this is the list of annotations on the method */ private void scan(Method method, Annotation label, Annotation[] list) throws Exception { if(label instanceof Attribute) { process(method, label, list); } if(label instanceof ElementUnion) { process(method, label, list); } if(label instanceof ElementListUnion) { process(method, label, list); } if(label instanceof ElementMapUnion) { process(method, label, list); } if(label instanceof ElementList) { process(method, label, list); } if(label instanceof ElementArray) { process(method, label, list); } if(label instanceof ElementMap) { process(method, label, list); } if(label instanceof Element) { process(method, label, list); } if(label instanceof Version) { process(method, label, list); } if(label instanceof Text) { process(method, label, list); } if(label instanceof Transient) { remove(method, label, list); } }
private OtherPathWithTextAndElementExample( @Path("valuePath/path") @Attribute(name="name") String a, @Path("someOtherPath/path") @Element(name="name") String b, @Text String c) { this.a = a; this.b = b; this.c = c; }
public void testMixedAnnotations() throws Exception { Map<String, Contact> map = getContacts(MixedAnnotations.class); assertFalse(map.get("array").isReadOnly()); assertFalse(map.get("map").isReadOnly()); assertFalse(map.get("name").isReadOnly()); assertFalse(map.get("value").isReadOnly()); assertEquals(String[].class, map.get("array").getType()); assertEquals(Map.class, map.get("map").getType()); assertEquals(int.class, map.get("value").getType()); assertEquals(String.class, map.get("name").getType()); assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType()); assertEquals(Element.class, map.get("value").getAnnotation().annotationType()); assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType()); assertEquals(ElementArray.class, map.get("array").getAnnotation().annotationType()); assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType()); assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType()); assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType()); assertEquals(ElementArray.class, map.get("array").getAnnotation(ElementArray.class).annotationType()); assertNull(map.get("name").getAnnotation(Root.class)); assertNull(map.get("value").getAnnotation(Root.class)); assertNull(map.get("map").getAnnotation(Root.class)); assertNull(map.get("array").getAnnotation(Root.class)); }
public void testExtendedAnnotations() throws Exception { Map<String, Contact> map = getContacts(ExtendedAnnotations.class); assertFalse(map.get("array").isReadOnly()); assertFalse(map.get("map").isReadOnly()); assertFalse(map.get("name").isReadOnly()); assertFalse(map.get("value").isReadOnly()); assertEquals(String[].class, map.get("array").getType()); assertEquals(Map.class, map.get("map").getType()); assertEquals(int.class, map.get("value").getType()); assertEquals(String.class, map.get("name").getType()); assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType()); assertEquals(Element.class, map.get("value").getAnnotation().annotationType()); assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType()); assertEquals(Element.class, map.get("array").getAnnotation().annotationType()); assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType()); assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType()); assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType()); assertEquals(Element.class, map.get("array").getAnnotation(Element.class).annotationType()); assertNull(map.get("name").getAnnotation(Root.class)); assertNull(map.get("value").getAnnotation(Root.class)); assertNull(map.get("map").getAnnotation(Root.class)); assertNull(map.get("array").getAnnotation(Root.class)); }
/** * Constructor for the <code>AttributeLabel</code> object. This * is used to create a label that can convert from an object to an * XML attribute and vice versa. This requires the annotation and * contact extracted from the XML schema class. * * @param contact this is the field from the XML schema class * @param label represents the annotation for the field * @param format this is the format used to style the path */ public AttributeLabel(Contact contact, Attribute label, Format format) { this.detail = new Introspector(contact, this, format); this.decorator = new Qualifier(contact); this.required = label.required(); this.type = contact.getType(); this.empty = label.empty(); this.name = label.name(); this.format = format; this.label = label; }
public Thumbnail(@Attribute(name = "url") String url, @Attribute(name = "width") int width, @Attribute(name = "height") int height) { this.url = url; this.width = width; this.height = height; }