Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 4 package com.openedit.modules.xml; 5 6 import java.util.ArrayList ; 7 import java.util.Iterator ; 8 import java.util.List ; 9 10 import org.dom4j.Element; 11 12 public class XmlFile 13 { 14 protected long fieldLastModified = -1; 15 protected String fieldPath; 16 protected String fieldId; 17 protected String fieldElementName; 18 19 protected Element fieldRoot; 20 protected List fieldAttributes; 21 protected boolean fieldExist; 22 23 public String getPath() 24 { 25 return fieldPath; 26 } 27 public void setPath(String inFile) 28 { 29 fieldPath = inFile; 30 } 31 public String getId() 32 { 33 return fieldId; 34 } 35 public void setId(String inId) 36 { 37 fieldId = inId; 38 } 39 public long getLastModified() 40 { 41 return fieldLastModified; 42 } 43 public void setLastModified(long inLastModified) 44 { 45 fieldLastModified = inLastModified; 46 } 47 public Element getRoot() 48 { 49 return fieldRoot; 50 } 51 public void setRoot(Element inRoot) 52 { 53 fieldRoot = inRoot; 54 } 55 public List getElements() 56 { 57 return getRoot().elements(getElementName()); 58 } 59 public List getAttributes() 60 { 61 if (fieldAttributes == null) 63 { 64 fieldAttributes = new ArrayList (); 65 } 66 return fieldAttributes; 67 } 68 public void addAttribute(AttributeDesc inDesc) 69 { 70 getAttributes().add(inDesc); 71 } 72 public Element getElementById(String inEid) 73 { 74 if( inEid == null) 75 { 76 return null; 77 } 78 for (Iterator iter = getElements().iterator(); iter.hasNext();) 79 { 80 Element element = (Element) iter.next(); 81 if ( inEid.equals(element.attributeValue("id"))) 82 { 83 return element; 84 } 85 } 86 return null; 87 } 88 public void deleteElement(Element inEid) 89 { 90 getRoot().remove(inEid); 91 } 92 public Element addNewElement() 93 { 94 Element child = getRoot().addElement(getElementName()); 95 for (Iterator iter = getAttributes().iterator(); iter.hasNext();) 96 { 97 AttributeDesc attrib = (AttributeDesc) iter.next(); 98 if ( attrib.getId().equals("id")) 99 { 100 child.addAttribute(attrib.getId(), "" + System.currentTimeMillis() ); 101 } 102 else 103 { 104 child.addAttribute(attrib.getId(), ""); } 106 } 107 return child; 108 } 109 public String getElementName() 110 { 111 return fieldElementName; 112 } 113 public void setElementName(String inElementName) 114 { 115 fieldElementName = inElementName; 116 } 117 public boolean isExist() 118 { 119 return fieldExist; 120 } 121 public void setExist(boolean inExist) 122 { 123 fieldExist = inExist; 124 } 125 } 126
| Popular Tags
|