/** Create a new codec factory. */ public CodecFactory() { // default_id = NuggetsCodec.CODEC_ID; default_id = JadexXMLCodec.CODEC_ID; codecclasses = SCollection.createHashMap(); codeccache = SCollection.createHashMap(); addCodec(SerialCodec.class); addCodec(NuggetsCodec.class); addCodec(XMLCodec.class); addCodec(JadexXMLCodec.class); }
/** Get all elements which have errors and are contained in the given element. */ protected Tuple[] getElementErrors(Object ancestor) { List errors = SCollection.createArrayList(); Tuple[] elements = getElements(); for (int i = 0; i < elements.length; i++) { boolean added = errors.contains(elements[i]); for (int j = 0; !added && j < elements[i].getEntities().length; j++) { Object se = elements[i].getEntity(j); Object obj = getPathElementObject(se); if (ancestor.equals(obj)) { errors.add(elements[i]); added = true; } } } return (Tuple[]) errors.toArray(new Tuple[errors.size()]); }
/** Get other errors, not in the given tags. */ protected Set getOtherErrors(Set excludes) { Set errors = SCollection.createLinkedHashSet(); Tuple[] elements = getElements(); for (int i = 0; i < elements.length; i++) { boolean excluded = false; for (int j = 0; !excluded && j < elements[i].getEntities().length; j++) { Object se = elements[i].getEntity(j); Object obj = getPathElementObject(se); if (obj != null) { excluded = excludes.contains(obj); } } if (!excluded) { Object obj = getObject(elements[i]); if (obj != null && !errors.contains(obj)) errors.add(obj); } } return errors; }
/** Get elements of the given owner type, which have errors or contain elements with errors. */ protected Set getOwnedElementErrors(String category) { Set errors = SCollection.createLinkedHashSet(); Tuple[] elements = getElements(); for (int i = 0; i < elements.length; i++) { boolean added = false; for (int j = 0; !added && j < elements[i].getEntities().length; j++) { Object se = elements[i].getEntity(j); Object obj = getPathElementObject(se); if (obj != null) { added = errors.contains(obj); if (!added && isInCategory(obj, category)) { errors.add(obj); added = true; } } } } return errors; }