comparison servlet/src/digilib/io/XMLMetaLoader.java @ 139:11cfe4c89fdc

Servlet version 1.11b1 with improved original-size. - fixed lots of bugs in metadata handling.
author robcast
date Thu, 31 Jul 2003 20:56:51 +0200
parents c36944be0b58
children bc8df0133c04
comparison
equal deleted inserted replaced
138:d18b0ff52b07 139:11cfe4c89fdc
54 private HashMap meta; 54 private HashMap meta;
55 private StringBuffer content; 55 private StringBuffer content;
56 private String fileName; 56 private String fileName;
57 private String filePath; 57 private String filePath;
58 58
59 // public HashMap getData() { 59 /**
60 // return meta; 60 * extracts the elements name from either localName ln or qName qn.
61 // } 61 *
62 * @param ln localName
63 * @param qn qName
64 * @return element name
65 */
66 private String getName(String ln, String qn) {
67 if (ln != null) {
68 if (ln.length() > 0) {
69 return ln;
70 }
71 }
72 // else it's qName (or nothing)
73 return qn;
74 }
62 75
63 // Parser calls this once at the beginning of a document 76 // Parser calls this once at the beginning of a document
64 public void startDocument() throws SAXException { 77 public void startDocument() throws SAXException {
65 tags = new LinkedList(); 78 tags = new LinkedList();
66 files = new HashMap(); 79 files = new HashMap();
72 String localName, 85 String localName,
73 String qName, 86 String qName,
74 Attributes atts) 87 Attributes atts)
75 throws SAXException { 88 throws SAXException {
76 89
77 String name = (localName != null) ? localName : qName; 90 String name = getName(localName, qName);
78 // open a new tag 91 // open a new tag
79 tags.addLast(name); 92 tags.addLast(name);
80 // start new content (no nesting of tags and content) 93 // start new content (no nesting of tags and content)
81 content = new StringBuffer(); 94 content = new StringBuffer();
82 95
85 meta = new HashMap(); 98 meta = new HashMap();
86 } else if (name.equals(fileTag)) { 99 } else if (name.equals(fileTag)) {
87 // new file tag 100 // new file tag
88 fileName = null; 101 fileName = null;
89 filePath = null; 102 filePath = null;
103 meta = new HashMap();
90 } 104 }
91 } 105 }
92 106
93 // parser calls this for all tag content (possibly more than once) 107 // parser calls this for all tag content (possibly more than once)
94 public void characters(char[] ch, int start, int length) 108 public void characters(char[] ch, int start, int length)
102 String namespaceURI, 116 String namespaceURI,
103 String localName, 117 String localName,
104 String qName) 118 String qName)
105 throws SAXException { 119 throws SAXException {
106 120
107 String name = (localName != null) ? localName : qName; 121 String name = getName(localName, qName);
108 // exit the tag 122 // exit the tag
109 tags.removeLast(); 123 tags.removeLast();
110 124
111 // was it a file.name tag? 125 // was it a file.name tag?
112 if (name.equals(fileNameTag) && tags.contains(fileTag)) { 126 if (name.equals(fileNameTag) && tags.contains(fileTag)) {