Project

General

Profile

« Previous | Next » 

Revision 4470

Added by daigle over 15 years ago

Add some generics typing. Fixed comments.

View differences:

src/edu/ucsb/nceas/metacat/DBSAXHandler.java
73 73

  
74 74
    private boolean stackCreated = false;
75 75

  
76
    protected Stack nodeStack;
76
    protected Stack<DBSAXNode> nodeStack;
77 77

  
78
    protected Vector nodeIndex;
78
    protected Vector<DBSAXNode> nodeIndex;
79 79

  
80 80
    protected DBConnection connection = null;
81 81

  
......
99 99

  
100 100
    protected String pub = null;
101 101

  
102
    private boolean endDocument = false;
102
//    private boolean endDocument = false;
103 103

  
104 104
    protected int serverCode = 1;
105 105

  
106
    protected Hashtable namespaces = new Hashtable();
106
    protected Hashtable<String,String> namespaces = new Hashtable<String,String>();
107 107

  
108 108
    protected boolean hitTextNode = false; // a flag to hit text node
109 109

  
110 110
    // a buffer to keep all text nodes for same element
111
    // it is for element was splited
111
    // it is for if element was split
112 112
    protected StringBuffer textBuffer = new StringBuffer();
113 113

  
114
    protected Stack textBufferStack = new Stack();
114
//    protected Stack textBufferStack = new Stack();
115 115

  
116 116
    protected static final int MAXDATACHARS = 4000;
117 117

  
......
156 156
        // Create the stack for keeping track of node context
157 157
        // if it doesn't already exist
158 158
        if (!stackCreated) {
159
            nodeStack = new Stack();
160
            nodeIndex = new Vector();
159
            nodeStack = new Stack<DBSAXNode>();
160
            nodeIndex = new Vector<DBSAXNode>();
161 161
            stackCreated = true;
162 162
        }
163 163
    }
......
237 237
		// It calls the run method of the thread.
238 238

  
239 239
		try {
240
			// if it is data package insert triple into relationtion table;
240
			// if it is data package insert triple into relation table;
241 241
			if (doctype != null
242 242
					&& MetaCatUtil.getOptionList(
243 243
							PropertyService.getProperty("xml.packagedoctype")).contains(
244 244
							doctype) && hasTriple && !isRevisionDoc) {
245 245

  
246
				// initial handler and write into relationdb only for
246
				// initial handler and write into relation db only for
247 247
				// xml-documents
248 248
				if (!isRevisionDoc) {
249 249
					RelationHandler handler = new RelationHandler(docid, doctype,
......
283 283
    {
284 284
        // for element <eml:eml...> qname is "eml:eml", local name is "eml"
285 285
        // for element <acl....> both qname and local name is "eml"
286
        // uri is namesapce
286
        // uri is namespace
287 287
        logMetacat.info("Start ELEMENT(qName) " + qName);
288 288
        logMetacat.info("Start ELEMENT(localName) " + localName);
289 289
        logMetacat.info("Start ELEMENT(uri) " + uri);
......
300 300
        }
301 301

  
302 302
        // If hit a text node, we need write this text for current's parent
303
        // node
304
        // This will happend if the element is mixted
303
        // node This will happen if the element is mixed
305 304
        if (hitTextNode && parentNode != null) {
306 305
            // write the textbuffer into db for parent node.
307 306
            endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, parentNode);
......
321 320
            if (docname == null) {
322 321
                docname = localName;
323 322
                // if uri isn't null doctype = uri(namespace)
324
                // othewise root element
323
                // otherwise root element
325 324
                if (uri != null && !(uri.trim()).equals("")) {
326 325
                    doctype = uri;
327 326
                } else {
......
343 342
                // Catalog
344 343
                // Because this is select statement and it needn't to roll back
345 344
                // if
346
                // insert document action fialed.
345
                // insert document action failed.
347 346
                // In order to decrease DBConnection usage count, we get a new
348 347
                // dbconnection from pool
349 348
               
......
400 399
        // Add all of the namespaces
401 400
        String prefix;
402 401
        String nsuri;
403
        Enumeration prefixes = namespaces.keys();
402
        Enumeration<String> prefixes = namespaces.keys();
404 403
        while (prefixes.hasMoreElements()) {
405 404
            prefix = (String) prefixes.nextElement();
406 405
            nsuri = (String) namespaces.get(prefix);
407 406
            currentNode.setNamespace(prefix, nsuri, docid);
408 407
        }
409 408
        namespaces = null;
410
        namespaces = new Hashtable();
409
        namespaces = new Hashtable<String,String>();
411 410

  
412 411
        // Add all of the attributes
413 412
        for (int i = 0; i < atts.getLength(); i++) {
......
467 466
    public void characters(char[] cbuf, int start, int len) throws SAXException
468 467
    {
469 468
        logMetacat.info("CHARACTERS");
470
        // buffer all text nodes for same element. This is for text was splited
469
        // buffer all text nodes for same element. This is for if text was split
471 470
        // into different nodes
472 471
        textBuffer.append(new String(cbuf, start, len));
473 472
        // set hittextnode true
......
808 807
        String data = null;
809 808

  
810 809
        String normalizedData = strBuffer.toString();
811
        logMetacat.debug("Before normailize in write process === "+normalizedData);
810
        logMetacat.debug("Before normalize in write process === "+normalizedData);
812 811
        String afterNormalize = MetaCatUtil.normalize(normalizedData);
813
        logMetacat.debug("After normailize in write process === "+afterNormalize);
812
        logMetacat.debug("After normalize in write process === "+afterNormalize);
814 813
        strBuffer = new StringBuffer(afterNormalize);;
815 814

  
816 815
        int bufferSize = strBuffer.length();

Also available in: Unified diff