/** * Checks if the {@link Annotation} is initialized. * * <p>An {@link Annotation} is initialized if * at least one of the following is true: * <ul> * <li> there is some non RDF annotation * <li> one or more {@link CVTerm} are defined * <li> there is an history defined. * </ul> * * @return {@code true} if the Annotation is initialized */ public boolean isSetAnnotation() { if ((getNonRDFannotation() == null) && getListOfCVTerms().isEmpty() && !isSetHistory()) { return false; } else if ((getNonRDFannotation() == null) && !isSetHistory() && !getListOfCVTerms().isEmpty()) { for (int i = 0; i < getListOfCVTerms().size(); i++) { if ((getCVTerm(i) != null) && getCVTerm(i).getResourceCount() > 0) { return true; } } } return true; }
@Override public Annotation clone() { return new Annotation(this); }
@Override public boolean addCVTerm(CVTerm term) { return getAnnotation().addCVTerm(term); }
/** * Returns the {@link History} of the Annotation. * * @return the {@link History} of the Annotation. */ public History getHistory() { if (!isSetHistory()) { createHistory(); } return history; }
/** * Sets the non RDF annotation String to {@code null}. */ public void unsetNonRDFannotation() { XMLNode oldNonRDFAnnotation = null; if (isSetNonRDFannotation()) { oldNonRDFAnnotation = nonRDFannotation; nonRDFannotation = null; firePropertyChange(TreeNodeChangeEvent.nonRDFAnnotation, oldNonRDFAnnotation, nonRDFannotation); } }
@Override public boolean equals(Object object) { boolean equals = super.equals(object); if (equals) { Annotation annotation = (Annotation) object; equals &= isSetNonRDFannotation() == annotation.isSetNonRDFannotation(); if (equals && isSetNonRDFannotation()) { equals &= nonRDFannotation.equals(annotation.getNonRDFannotation()); } equals &= isSetAbout() == annotation.isSetAbout(); if (equals && isSetAbout()) { equals &= getAbout().equals(annotation.getAbout()); } } return equals; }
/** * Creates a new Annotation instance by cloning the given Annotation. * * @param annotation the annotation to be cloned. */ public Annotation(Annotation annotation) { super(annotation); if (annotation.nonRDFannotation != null) { nonRDFannotation = annotation.nonRDFannotation.clone(); } for (CVTerm term : annotation.getListOfCVTerms()) { getListOfCVTerms().add(term.clone()); } if (annotation.isSetHistory()) { setHistory(annotation.getHistory().clone()); } }
if (isSetHistory()) { if (childIndex == pos) { return getHistory(); if (isSetListOfCVTerms()) { if (childIndex == pos) { return new TreeNodeAdapter(getListOfCVTerms(), this);
@Override public boolean hasValidAnnotation() { if (isSetAnnotation()) { if (isSetMetaId()) { Annotation annotation = getAnnotation(); if (!annotation.isSetAbout()) { /* * Ok, let's set this about tag silently because * when writing SBML, we would set this tag anyway. * This method just complains incorrectly set about * tags. */ annotation.setAbout('#' + getMetaId()); return true; } if (annotation.getAbout().equals('#' + getMetaId())) { return true; } } if (getAnnotation().isSetNonRDFannotation() && !getAnnotation().isSetRDFannotation()) { return true; } return false; } return true; }
/** * Checks if the RDF part of the Annotation is initialized. * * <p>An Annotation is initialized if * at least one of the following is true: * <ul> * <li> one or more CVTerm are defined * <li> there is an history defined. * </ul> * <p> * * @return {@code true} if the RDF part of the Annotation is initialized */ public boolean isSetRDFannotation() { if (getListOfCVTerms().isEmpty() && (!isSetHistory())) { return false; } else if ((!isSetHistory()) && !getListOfCVTerms().isEmpty()) { for (int i = 0; i < getListOfCVTerms().size(); i++) { if (getCVTerm(i) != null) { return true; } } } return true; }
@Override public int getCVTermCount() { return isSetAnnotation() ? annotation.getListOfCVTerms().size() : 0; }
/** * Returns a list of CVTerm having the given qualifier. * * @param qualifier the qualifier * @return a list of CVTerm having the given qualifier, an empty * list is returned if no CVTerm are found. */ public List<CVTerm> filterCVTerms(Qualifier qualifier) { ArrayList<CVTerm> l = new ArrayList<CVTerm>(); CVTermFilter filter = new CVTermFilter(qualifier); for (CVTerm term : getListOfCVTerms()) { if (filter.accepts(term)) { l.add(term); } if (term.getNestedCVTermCount() > 0) { l.addAll(filterCVTerms(qualifier, term.getListOfNestedCVTerms())); } } return l; }
/** * Sets the {@link History} instance of this object to {@code null}. */ public void unsetHistory() { History oldHistory = null; if (history != null) { oldHistory = history; } history = null; firePropertyChange(TreeNodeChangeEvent.history, oldHistory, history); }
/** * Changes the {@link History} instance to 'history' * * @param history the history to set. */ public void setHistory(History history) { History oldHistory = this.history; this.history = history; this.history.parent = this; this.history.addAllChangeListeners(getListOfTreeNodeChangeListeners()); firePropertyChange(TreeNodeChangeEvent.history, oldHistory, this.history); }
@Override public void appendAnnotation(String annotation) throws XMLStreamException { getAnnotation().appendNonRDFAnnotation(annotation); }
@Override public List<CVTerm> filterCVTerms(CVTerm.Qualifier qualifier) { return getAnnotation().filterCVTerms(qualifier); }
annotation.addDeclaredNamespace(prefix + ":" + localName, URI); } else { annotation.addDeclaredNamespace(localName, URI);
setAnnotation(sb.getAnnotation().clone());
descriptionNode.addAttr("about", contextObject.getAnnotation().getAbout(), Annotation.URI_RDF_SYNTAX_NS, "rdf");