Revision 9960
Added by Jing Tao about 8 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
232 | 232 |
/** SAX Handler that receives notification of beginning of the document */ |
233 | 233 |
public void startDocument() throws SAXException |
234 | 234 |
{ |
235 |
logMetacat.debug("DBSaxHandler.startDocument - starting document");
|
|
235 |
logMetacat.trace("DBSaxHandler.startDocument - starting document");
|
|
236 | 236 |
|
237 | 237 |
// Create the document node representation as root |
238 | 238 |
rootNode = new DBSAXNode(connection, this.docid); |
... | ... | |
243 | 243 |
|
244 | 244 |
/** SAX Handler that receives notification of end of the document */ |
245 | 245 |
public void endDocument() throws SAXException { |
246 |
logMetacat.debug("DBSaxHandler.endDocument - ending document");
|
|
246 |
logMetacat.trace("DBSaxHandler.endDocument - ending document");
|
|
247 | 247 |
// Starting new thread for writing XML Index. |
248 | 248 |
// It calls the run method of the thread. |
249 | 249 |
|
... | ... | |
283 | 283 |
public void startPrefixMapping(String prefix, String uri) |
284 | 284 |
throws SAXException |
285 | 285 |
{ |
286 |
logMetacat.debug("DBSaxHandler.startPrefixMapping - Starting namespace");
|
|
286 |
logMetacat.trace("DBSaxHandler.startPrefixMapping - Starting namespace");
|
|
287 | 287 |
|
288 | 288 |
namespaces.put(prefix, uri); |
289 | 289 |
} |
... | ... | |
295 | 295 |
// for element <eml:eml...> qname is "eml:eml", local name is "eml" |
296 | 296 |
// for element <acl....> both qname and local name is "eml" |
297 | 297 |
// uri is namespace |
298 |
logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(qName) " + qName);
|
|
299 |
logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(localName) " + localName);
|
|
300 |
logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(uri) " + uri);
|
|
298 |
logMetacat.trace("DBSaxHandler.startElement - Start ELEMENT(qName) " + qName);
|
|
299 |
logMetacat.trace("DBSaxHandler.startElement - Start ELEMENT(localName) " + localName);
|
|
300 |
logMetacat.trace("DBSaxHandler.startElement - Start ELEMENT(uri) " + uri);
|
|
301 | 301 |
|
302 | 302 |
DBSAXNode parentNode = null; |
303 | 303 |
DBSAXNode currentNode = null; |
... | ... | |
482 | 482 |
/** SAX Handler that is called for each XML text node */ |
483 | 483 |
public void characters(char[] cbuf, int start, int len) throws SAXException |
484 | 484 |
{ |
485 |
logMetacat.debug("DBSaxHandler.characters - starting characters");
|
|
485 |
logMetacat.trace("DBSaxHandler.characters - starting characters");
|
|
486 | 486 |
// buffer all text nodes for same element. This is for if text was split |
487 | 487 |
// into different nodes |
488 | 488 |
textBuffer.append(new String(cbuf, start, len)); |
... | ... | |
491 | 491 |
// if text buffer .size is greater than max, write it to db. |
492 | 492 |
// so we can save memory |
493 | 493 |
if (textBuffer.length() > MAXDATACHARS) { |
494 |
logMetacat.debug("DBSaxHandler.characters - Write text into DB in charaters"
|
|
494 |
logMetacat.trace("DBSaxHandler.characters - Write text into DB in charaters"
|
|
495 | 495 |
+ " when text buffer size is greater than maxmum number"); |
496 | 496 |
DBSAXNode currentNode = (DBSAXNode) nodeStack.peek(); |
497 | 497 |
endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, |
... | ... | |
511 | 511 |
// When validation is turned "on", white spaces are reported here |
512 | 512 |
// When validation is turned "off" white spaces are not reported here, |
513 | 513 |
// but through characters() callback |
514 |
logMetacat.debug("DBSaxHandler.ignorableWhitespace - in ignorableWhitespace");
|
|
514 |
logMetacat.trace("DBSaxHandler.ignorableWhitespace - in ignorableWhitespace");
|
|
515 | 515 |
|
516 | 516 |
DBSAXNode currentNode = (DBSAXNode) nodeStack.peek(); |
517 | 517 |
|
... | ... | |
527 | 527 |
public void processingInstruction(String target, String data) |
528 | 528 |
throws SAXException |
529 | 529 |
{ |
530 |
logMetacat.debug("DBSaxHandler.processingInstruction - in processing instructions");
|
|
530 |
logMetacat.trace("DBSaxHandler.processingInstruction - in processing instructions");
|
|
531 | 531 |
DBSAXNode currentNode = (DBSAXNode) nodeStack.peek(); |
532 | 532 |
endNodeId = currentNode.writeChildNodeToDB("PI", target, data, docid); |
533 | 533 |
} |
... | ... | |
536 | 536 |
public void endElement(String uri, String localName, String qName) |
537 | 537 |
throws SAXException |
538 | 538 |
{ |
539 |
logMetacat.debug("DBSaxHandler.endElement - End element " + qName);
|
|
539 |
logMetacat.trace("DBSaxHandler.endElement - End element " + qName);
|
|
540 | 540 |
|
541 | 541 |
// write buffered text nodes into db (so no splited) |
542 | 542 |
DBSAXNode currentNode = (DBSAXNode) nodeStack.peek(); |
... | ... | |
545 | 545 |
// into the buffer, write the buffer to data base. The reason we put |
546 | 546 |
// write database here is for xerces some time split text node |
547 | 547 |
if (hitTextNode) { |
548 |
logMetacat.debug("DBSaxHandler.endElement - Write text into DB in End Element");
|
|
548 |
logMetacat.trace("DBSaxHandler.endElement - Write text into DB in End Element");
|
|
549 | 549 |
endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, |
550 | 550 |
currentNode); |
551 | 551 |
|
... | ... | |
603 | 603 |
// we don't put the dtd node into node stack |
604 | 604 |
DBSAXNode dtdNode = new DBSAXNode(connection, name, publicId, systemId, |
605 | 605 |
currentNode, currentNode.getRootNodeID(), docid); |
606 |
logMetacat.debug("DBSaxHandler.startDTD - Start DTD");
|
|
607 |
logMetacat.debug("DBSaxHandler.startDTD - Setting processingDTD to true");
|
|
608 |
logMetacat.debug("DBSaxHandler.startDTD - DOCNAME: " + docname);
|
|
609 |
logMetacat.debug("DBSaxHandler.startDTD - DOCTYPE: " + doctype);
|
|
610 |
logMetacat.debug("DBSaxHandler.startDTD - SYSID: " + systemid);
|
|
606 |
logMetacat.trace("DBSaxHandler.startDTD - Start DTD");
|
|
607 |
logMetacat.trace("DBSaxHandler.startDTD - Setting processingDTD to true");
|
|
608 |
logMetacat.trace("DBSaxHandler.startDTD - DOCNAME: " + docname);
|
|
609 |
logMetacat.trace("DBSaxHandler.startDTD - DOCTYPE: " + doctype);
|
|
610 |
logMetacat.trace("DBSaxHandler.startDTD - SYSID: " + systemid);
|
|
611 | 611 |
} |
612 | 612 |
|
613 | 613 |
/** |
... | ... | |
617 | 617 |
{ |
618 | 618 |
|
619 | 619 |
processingDTD = false; |
620 |
logMetacat.debug("DBSaxHandler.endDTD - Setting processingDTD to false");
|
|
621 |
logMetacat.debug("DBSaxHandler.endDTD - end DTD");
|
|
620 |
logMetacat.trace("DBSaxHandler.endDTD - Setting processingDTD to false");
|
|
621 |
logMetacat.trace("DBSaxHandler.endDTD - end DTD");
|
|
622 | 622 |
} |
623 | 623 |
|
624 | 624 |
/** |
... | ... | |
626 | 626 |
*/ |
627 | 627 |
public void comment(char[] ch, int start, int length) throws SAXException |
628 | 628 |
{ |
629 |
logMetacat.debug("DBSaxHandler.comment - starting comment");
|
|
629 |
logMetacat.trace("DBSaxHandler.comment - starting comment");
|
|
630 | 630 |
if (!processingDTD) { |
631 | 631 |
DBSAXNode currentNode = (DBSAXNode) nodeStack.peek(); |
632 | 632 |
endNodeId = currentNode.writeChildNodeToDB("COMMENT", null, |
... | ... | |
639 | 639 |
*/ |
640 | 640 |
public void startCDATA() throws SAXException |
641 | 641 |
{ |
642 |
logMetacat.debug("DBSaxHandler.startCDATA - starting CDATA");
|
|
642 |
logMetacat.trace("DBSaxHandler.startCDATA - starting CDATA");
|
|
643 | 643 |
} |
644 | 644 |
|
645 | 645 |
/** |
... | ... | |
647 | 647 |
*/ |
648 | 648 |
public void endCDATA() throws SAXException |
649 | 649 |
{ |
650 |
logMetacat.debug("DBSaxHandler.endCDATA - end CDATA");
|
|
650 |
logMetacat.trace("DBSaxHandler.endCDATA - end CDATA");
|
|
651 | 651 |
} |
652 | 652 |
|
653 | 653 |
/** |
... | ... | |
655 | 655 |
*/ |
656 | 656 |
public void startEntity(String name) throws SAXException |
657 | 657 |
{ |
658 |
logMetacat.debug("DBSaxHandler.startEntity - starting entity: " + name);
|
|
658 |
logMetacat.trace("DBSaxHandler.startEntity - starting entity: " + name);
|
|
659 | 659 |
//System.out.println("start ENTITY: " + name); |
660 | 660 |
if (name.equals("[dtd]")) { |
661 | 661 |
processingDTD = true; |
... | ... | |
667 | 667 |
*/ |
668 | 668 |
public void endEntity(String name) throws SAXException |
669 | 669 |
{ |
670 |
logMetacat.debug("DBSaxHandler.endEntity - ending entity: " + name);
|
|
670 |
logMetacat.trace("DBSaxHandler.endEntity - ending entity: " + name);
|
|
671 | 671 |
//System.out.println("end ENTITY: " + name); |
672 | 672 |
if (name.equals("[dtd]")) { |
673 | 673 |
processingDTD = false; |
... | ... | |
681 | 681 |
throws org.xml.sax.SAXException |
682 | 682 |
{ |
683 | 683 |
//System.out.println("ELEMENTDECL: " + name + " " + model); |
684 |
logMetacat.debug("DBSaxHandler.elementDecl - element declaration: " + name + " " + model);
|
|
684 |
logMetacat.trace("DBSaxHandler.elementDecl - element declaration: " + name + " " + model);
|
|
685 | 685 |
} |
686 | 686 |
|
687 | 687 |
/** |
... | ... | |
694 | 694 |
//System.out.println("ATTRIBUTEDECL: " + eName + " " |
695 | 695 |
// + aName + " " + type + " " + valueDefault + " " |
696 | 696 |
// + value); |
697 |
logMetacat.debug("DBSaxHandler.attributeDecl - attribute declaration: " + eName + " " + aName + " "
|
|
697 |
logMetacat.trace("DBSaxHandler.attributeDecl - attribute declaration: " + eName + " " + aName + " "
|
|
698 | 698 |
+ type + " " + valueDefault + " " + value); |
699 | 699 |
} |
700 | 700 |
|
... | ... | |
705 | 705 |
throws org.xml.sax.SAXException |
706 | 706 |
{ |
707 | 707 |
//System.out.println("INTERNENTITYDECL: " + name + " " + value); |
708 |
logMetacat.debug("DBSaxHandler.internalEntityDecl - internal entity declaration: " + name + " " + value);
|
|
708 |
logMetacat.trace("DBSaxHandler.internalEntityDecl - internal entity declaration: " + name + " " + value);
|
|
709 | 709 |
} |
710 | 710 |
|
711 | 711 |
/** |
... | ... | |
716 | 716 |
{ |
717 | 717 |
//System.out.println("EXTERNENTITYDECL: " + name + " " + publicId |
718 | 718 |
// + " " + systemId); |
719 |
logMetacat.debug("DBSaxHandler.externalEntityDecl - external entity declaration: " + name + " " + publicId
|
|
719 |
logMetacat.trace("DBSaxHandler.externalEntityDecl - external entity declaration: " + name + " " + publicId
|
|
720 | 720 |
+ " " + systemId); |
721 | 721 |
// it processes other external entity, not the DTD; |
722 | 722 |
// it doesn't signal for the DTD here |
... | ... | |
811 | 811 |
boolean moredata = true; |
812 | 812 |
|
813 | 813 |
String normalizedData = strBuffer.toString(); |
814 |
logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - Before normalize in write process: " + normalizedData);
|
|
814 |
logMetacat.trace("DBSAXHandler.writeTextForDBSAXNode - Before normalize in write process: " + normalizedData);
|
|
815 | 815 |
String afterNormalize = MetacatUtil.normalize(normalizedData); |
816 |
logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - After normalize in write process: " + afterNormalize);
|
|
816 |
logMetacat.trace("DBSAXHandler.writeTextForDBSAXNode - After normalize in write process: " + afterNormalize);
|
|
817 | 817 |
strBuffer = new StringBuffer(afterNormalize);; |
818 | 818 |
|
819 | 819 |
int bufferSize = strBuffer.length(); |
... | ... | |
821 | 821 |
|
822 | 822 |
// if there are some cotent in buffer, write it |
823 | 823 |
if (bufferSize > 0) { |
824 |
logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - Write text into DB");
|
|
824 |
logMetacat.trace("DBSAXHandler.writeTextForDBSAXNode - Write text into DB");
|
|
825 | 825 |
|
826 | 826 |
// Write the content of the node to the database |
827 | 827 |
nodeId = node.writeChildNodeToDB("TEXT", null, new String(strBuffer), docid); |
Also available in: Unified diff
Down the debug level from debug to trace.