use of org.jdom.Attribute in project vcell by virtualcell.
the class XmlElementComparator method compare.
/**
* compare method comment.
*/
public int compare(Element o1, Element o2) {
if (o1 == null || o2 == null) {
throw new IllegalArgumentException("Cannot compare against null's!");
}
// compare their names
if (!diffTree.getMangledName(o1).equalsIgnoreCase(diffTree.getMangledName(o2))) {
this.status = this.DIFNAMETAG;
return java.lang.Integer.MIN_VALUE;
}
// compare their attributes
List baselist = o1.getAttributes();
List modifiedlist = o2.getAttributes();
if (baselist.size() != modifiedlist.size()) {
this.status = this.DIFATTRIBUTES;
return -1;
}
Iterator baseiterator = baselist.iterator();
Iterator moditerator = modifiedlist.iterator();
//
if (o1.getName().equals(cbit.vcell.xml.XMLTags.VersionTag) && diffTree.isIgnoringVersionInfo()) {
return 0;
}
while (baseiterator.hasNext() && moditerator.hasNext()) {
if (compare((Attribute) (baseiterator.next()), (Attribute) (moditerator.next())) != 0) {
this.status = this.DIFATTRIBUTES;
return -1;
}
}
// compare their subelements
List list1 = o1.getChildren();
List list2 = o2.getChildren();
if (list1.size() != list2.size()) {
this.status = this.DIFSUBELEMENTS;
return (list1.size() - list2.size());
}
int i = 0;
int differences = 0;
while (i < list1.size()) {
if (compare(list1.get(i), list2.get(i)) != 0) {
differences++;
}
i++;
}
if (differences != 0) {
this.status = this.DIFSUBELEMENTS;
return differences;
}
// compare content
if (!o1.getText().equalsIgnoreCase(o2.getText())) {
// compare their content
this.status = this.DIFCONTENT;
return o1.getText().compareTo(o2.getText());
}
return 0;
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class CellQuanVCTranslator method fixMathMLBug.
// temporary method.
private void fixMathMLBug(Element math) {
ArrayList<Element> l = new ArrayList<Element>();
@SuppressWarnings("unchecked") Iterator<Element> walker = new JDOMTreeWalker(math, new ContentFilter(ContentFilter.ELEMENT));
while (walker.hasNext()) l.add(walker.next());
Element temp;
for (int i = 0; i < l.size(); i++) {
temp = l.get(i);
if (temp.getName().equals(MathMLTags.CONSTANT)) {
@SuppressWarnings("unchecked") ArrayList<Attribute> atts = new ArrayList<Attribute>(temp.getAttributes());
org.jdom.Attribute att;
for (int j = 0; j < atts.size(); j++) {
att = atts.get(j);
temp.removeAttribute(att.getName(), mathns);
}
temp.removeNamespaceDeclaration(mathns);
}
}
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class PathwayReaderBiopax3 method addAttributes.
private void addAttributes(BioPaxObject bioPaxObject, Element element) {
int count = 0;
for (Object attr : element.getAttributes()) {
Attribute attribute = (Attribute) attr;
if (attribute.getName().equals("ID")) {
if (bioPaxObject instanceof RdfObjectProxy) {
showUnexpected(attribute);
} else {
String uri = context.unAbbreviateURI(element, attribute.getValue());
bioPaxObject.setID(uri);
count++;
}
} else if (attribute.getName().equals("resource")) {
if (bioPaxObject instanceof RdfObjectProxy) {
String uri = context.unRelativizeURI(element, attribute.getValue());
bioPaxObject.setID(uri);
count++;
} else {
showUnexpected(attribute);
}
} else if (attribute.getName().equals("about")) {
if (bioPaxObject instanceof RdfObjectProxy) {
// TODO: can this ever happen?
String uri = context.unRelativizeURI(element, attribute.getValue());
bioPaxObject.setID(uri);
count++;
} else {
String uri = context.unRelativizeURI(element, attribute.getValue());
bioPaxObject.setID(uri);
count++;
}
} else if (attribute.getName().equals("nodeID")) {
if (bioPaxObject instanceof RdfObjectProxy) {
// TODO: can this ever happen?
((RdfObjectProxy) bioPaxObject).setID(attribute.getValue());
count++;
} else {
bioPaxObject.setID(attribute.getValue());
count++;
}
} else {
showUnexpected(attribute);
}
}
if (count < 1) {
System.out.println(element + " has neither ID nor resource attributes.");
}
if (count > 1) {
System.out.println(element + " has multiple ID and/or resource attributes.");
}
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class PathwayReader method addContentControl.
private boolean addContentControl(Control control, Element element, Element childElement) {
if (addContentInteraction(control, element, childElement)) {
return true;
}
/**
* InteractionImpl controlledInteraction
* Pathway controlledPathway
* String controlType
* ArrayList<Pathway> pathwayControllers
* ArrayList<PhysicalEntity> physicalControllers
*/
if (childElement.getName().equals("CONTROLLER")) {
Element physicalEntityParticipantElement = childElement.getChild("physicalEntityParticipant", bp);
if (physicalEntityParticipantElement != null) {
Element physicalEntityPropertyElement = physicalEntityParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
control.addPhysicalController(physicalEntityProxy);
return true;
}
}
}
Element sequenceParticipantElement = childElement.getChild("sequenceParticipant", bp);
if (sequenceParticipantElement != null) {
Element physicalEntityPropertyElement = sequenceParticipantElement.getChild("PHYSICAL-ENTITY", bp);
if (physicalEntityPropertyElement != null) {
if (physicalEntityPropertyElement.getChildren().size() == 0) {
PhysicalEntityProxy physicalEntityProxy = new PhysicalEntityProxy();
addAttributes(physicalEntityProxy, physicalEntityPropertyElement);
pathwayModel.add(physicalEntityProxy);
control.addPhysicalController(physicalEntityProxy);
return true;
}
}
}
// }
return false;
// // is it a pathway controller?
// control.getPathwayControllers().add(addPathway(childElement));
} else if (childElement.getName().equals("CONTROLLED")) {
Attribute resourceAttribute = childElement.getAttribute("resource", rdf);
if (resourceAttribute != null) {
InteractionOrPathwayProxy controlledEntityProxy = new InteractionOrPathwayProxy();
control.setControlledInteraction(controlledEntityProxy);
pathwayModel.add(controlledEntityProxy);
String uri = context.unRelativizeURI(childElement, resourceAttribute.getValue());
controlledEntityProxy.setID(uri);
return true;
}
return false;
} else if (childElement.getName().equals("CONTROL-TYPE")) {
control.setControlType(childElement.getTextTrim());
return true;
} else {
return false;
}
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class PathwayReader method addAttributes.
private void addAttributes(BioPaxObject bioPaxObject, Element element) {
for (Object attr : element.getAttributes()) {
Attribute attribute = (Attribute) attr;
if (attribute.getName().equals("ID")) {
if (bioPaxObject instanceof RdfObjectProxy) {
showUnexpected(attribute, bioPaxObject);
} else {
String uri = context.unAbbreviateURI(element, attribute.getValue());
bioPaxObject.setID(uri);
}
} else if (attribute.getName().equals("resource")) {
if (bioPaxObject instanceof RdfObjectProxy) {
String uri = context.unRelativizeURI(element, attribute.getValue());
bioPaxObject.setID(uri);
} else {
showUnexpected(attribute, bioPaxObject);
}
} else {
showUnexpected(attribute, bioPaxObject);
}
}
}
Aggregations