1 package de.webman.generator; 2 3 import com.teamkonzept.db.*; 4 import com.teamkonzept.lib.*; 5 import com.teamkonzept.webman.db.*; 6 import de.webman.generator.db.queries.*; 7 8 import java.io.*; 9 import java.util.*; 10 import java.sql.*; 11 import org.apache.log4j.Category; 12 13 17 public class SiteNode implements Visitable 18 { 19 20 23 GeneratorContext context; 24 25 public final static int NODE_TYPE_SINGLE = 3; 26 public final static int NODE_TYPE_GROUP = 2; 27 28 public final static int DOC_TRAV_MODE_CONTENT = 1; 29 public final static int DOC_TRAV_MODE_REFERENCE = 2; 30 public final static int DOC_TRAV_MODE_STRUCT_CONTENT = 3; 31 32 33 private static Category cat = Category.getInstance(SiteNode.class.getName()); 34 35 36 private int id; 37 38 39 private SiteNode parent; 40 41 42 private int type; 43 44 45 private String shortName; 46 47 48 private String name; 49 50 51 private SiteContentNode primaryContentNode; 52 53 54 private String primaryContentSelectionType; 55 56 57 private String primaryContentSelectionData; 58 59 60 private String primaryContentSelectionKey; 61 62 63 private TKVector childs; 65 66 private TKVector documents; 68 69 private TKVector realDocuments; 71 72 private TKHashtable docNameHash; 74 75 private TKHashtable structureContents; 77 78 private TKVector genNodes; 81 84 private boolean isComplete; 85 86 private int level; 88 public SiteNode( GeneratorContext context, ResultSet rs, SiteNode lastInsertedNode ) 89 throws SQLException 90 { 91 this.context = context != null ? context : GeneratorContext.setup (); 92 93 this.id = rs.getInt("SITE_NODE_ID"); 94 this.type = rs.getInt("SITE_NODE_TYPE"); 95 this.shortName = rs.getString( "SITE_NODE_SHORTNAME" ); 96 name = rs.getString("SITE_NODE_NAME"); 97 if( lastInsertedNode == null ) { 98 parent = null; 99 level = 0; 100 } 101 else { 102 int parentId = rs.getInt("SITE_NODE_PARENT"); 103 while( lastInsertedNode.id != parentId ) { 104 lastInsertedNode = lastInsertedNode.parent; 105 } 106 parent = lastInsertedNode; 107 parent.childs.addElement( this ); 108 level = parent.level + 1; 109 } 110 111 if ( this.type == NODE_TYPE_GROUP ) { 112 int primaryContentNodeId = rs.getInt( "PG_CONTENT_NODE" ); 113 if( rs.wasNull() ) throw new Error ( "Primary Content-Node not set" ); 114 this.primaryContentNode = this.context.contentNodes.getContentNode( primaryContentNodeId ); 115 this.primaryContentSelectionType = rs.getString( "SELECTION_TYPE" ); 116 this.primaryContentSelectionData = rs.getString( "SELECTION_DATA" ); 117 } 118 else if( this.type != NODE_TYPE_SINGLE ) { 119 throw new Error ( "Unexpected Node-Type:"+type ); 120 } 121 122 this.childs = new TKVector(); 123 this.documents = new TKVector(); 124 realDocuments = new TKVector(); 125 this.docNameHash = new TKHashtable(); 126 this.structureContents = null; 127 this.isComplete = !this.context.siteNodes.isReducedBuild() && !this.context.siteNodes.isIndexBuild(); 128 129 if (this.context.siteNodes.getSubtreeNode() == null) 130 { 131 if (this.context.siteNodes.getSubtreeId() == this.id) 132 { 133 if (this.parent == null) this.context.siteNodes.setSubtreeId( -1); 134 else 135 { 136 this.context.siteNodes.setSubtreeNode(this); 137 this.context.siteNodes.setSubtreePath (getPath()); 138 } 139 } else if (this.context.siteNodes.getSubtreePath() != null) 140 { 141 String thisPath = getPath(); 142 if ((thisPath != null) && thisPath.equals (this.context.siteNodes.getSubtreePath())) 143 { 144 if (this.parent == null) this.context.siteNodes.setSubtreePath (null); 145 else 146 { 147 this.context.siteNodes.setSubtreeNode(this); 148 this.context.siteNodes.setSubtreeId (this.id); 149 } 150 } 151 } 152 } 153 } 154 155 public int getLevel() 156 { 157 return level; 158 } 159 160 public SiteContentNode getPrimaryContentNode() 161 { 162 return primaryContentNode; 163 } 164 165 public String getPrimaryContentSelectionType() 166 { 167 return primaryContentSelectionType; 168 } 169 170 public String getPrimaryContentSelectionData() 171 { 172 return primaryContentSelectionData; 173 } 174 175 public String getPrimaryContentSelectionKey() 176 { 177 return primaryContentSelectionKey; 178 } 179 180 public TKVector getChilds() 181 { 182 return childs; 183 } 184 185 public String getShortName() 186 { 187 return shortName; 188 } 189 190 public TKVector getGenNodes() 191 { 192 return genNodes; 193 } 194 195 public TKHashtable getStructureContents() 196 { 197 return structureContents; 198 } 199 200 public TKHashtable getDocumentNameHash() 201 { 202 return docNameHash; 203 } 204 205 public TKVector getDocuments() 206 { 207 return documents; 208 } 209 210 public String path() 211 { 212 if( parent == null ) return shortName; 213 return parent.path()+'.'+shortName; 214 } 215 216 public String toString() 217 { 218 String path = path(); 219 String result = 220 "<sitenode '"+path+"'>"+ 221 " id = "+id+ 222 " type = " +(type==NODE_TYPE_SINGLE?"SINGLE":"GROUP")+ 223 " "; 224 225 result += " sitenode documents:"; 226 Enumeration e = documents.elements(); 227 while( e.hasMoreElements() ) { 228 Object o = e.nextElement(); 229 if( o != null ) 230 result += " "+o; 231 } 232 233 result += " sitenode childs:"; 234 e = childs.elements(); 235 while( e.hasMoreElements() ) { 236 result += " "+e.nextElement(); 237 } 238 return result+" </sitenode '"+path+"'> "; 239 } 240 241 246 public String getPath() 247 { 248 return ( parent == null ? "/" : parent.getPath() + shortName + "/" ) ; 249 } 250 251 254 public String getDirPath() 255 { 256 return ( parent == null ? File.separator : parent.getDirPath() + shortName + File.separator) ; 257 } 258 259 263 public String getPathDir() 264 { 265 return ( parent == null ? "" : parent.getDirPath() + shortName) ; 266 } 267 268 public SiteNode getParent() 269 { 270 return parent; 271 } 272 273 public int getType() 274 { 275 return type; 276 } 277 278 public int getId() 279 { 280 return id; 281 } 282 283 public int addDocuments( ResultSet rs, int docNodeId ) 284 throws SQLException 285 { 286 while (context.siteNodes.getNode (docNodeId) == null) { 288 289 if( !rs.next() ) return -1; 290 docNodeId = rs.getInt( "SITE_NODE_ID" ); 291 } 292 294 while( docNodeId == id ) { 295 SiteDocument doc = new SiteDocument( context, rs, this ); 296 documents.put( doc.getIndex(), doc ); 297 if( !rs.next() ) return -1; 298 docNodeId = rs.getInt( "SITE_NODE_ID" ); 299 } 300 301 Enumeration e = childs.elements(); 302 while( e.hasMoreElements() ) { 303 SiteNode child = (SiteNode) e.nextElement(); 304 docNodeId = child.addDocuments( rs, docNodeId ); 305 if( docNodeId == -1 ) 306 return -1; 307 } 308 return docNodeId; 309 } 310 311 public void readDocuments() 312 throws SQLException 313 { 314 TKQuery q = TKWebmanDBManager.newQuery(GenSiteDocs.class); 315 q.execute(); 316 ResultSet rs = q.fetchResultSet(); 317 318 if( rs.next() ) { 319 addDocuments( rs, rs.getInt( "SITE_NODE_ID" ) ); 320 } 321 } 322 323 public int traverseDocuments( 324 int mode, 325 String nodeColName, 326 String idxColName, 327 ResultSet rs, 328 int docNodeId, 329 int docIdx 330 ) 331 throws SQLException 332 { 333 while (context.siteNodes.getNode (docNodeId) == null) { 335 336 if( !rs.next() ) return 0; 337 338 docNodeId = rs.getInt(nodeColName); 339 docIdx = rs.getInt(idxColName); 340 } 341 343 int res; 344 while( docNodeId == id ) { 346 SiteDocument doc = 347 (SiteDocument) documents.get( docIdx ); 348 res = doc.traverse( mode, nodeColName, idxColName, rs, docNodeId ); 349 if( res == 0 ) 350 return 0; 351 352 if( res > 0 ) { 353 docIdx = res; 354 } 355 else { 356 docNodeId = -res; 357 docIdx = rs.getInt( idxColName ); 358 } 359 } 360 361 Enumeration e = childs.elements(); 362 while( e.hasMoreElements() ) { 363 SiteNode child = (SiteNode) e.nextElement(); 364 res = child.traverseDocuments( mode, nodeColName, idxColName, rs, docNodeId, docIdx ); 365 if( res == 0 ) 366 return 0; 367 368 if( res > 0 ) { 369 docIdx = res; 370 } 371 else { 372 docNodeId = -res; 373 docIdx = rs.getInt( idxColName ); 374 } 375 } 376 return -docNodeId; 377 } 378 379 public void readReferences() 380 throws SQLException 381 { 382 TKQuery q = TKWebmanDBManager.newQuery(GenSiteRefs.class); 383 q.execute(); 384 ResultSet rs = q.fetchResultSet(); 385 386 if( rs.next() ) { 387 traverseDocuments( 388 DOC_TRAV_MODE_REFERENCE, 389 "SRC_SITE_NODE_ID", 390 "SRC_SITE_NODE_DOC_IDX", 391 rs, 392 rs.getInt( "SRC_SITE_NODE_ID" ), 393 rs.getInt( "SRC_SITE_NODE_DOC_IDX" ) 394 ); 395 } 396 } 397 398 public int addStructureContents( ResultSet rs, int docNodeId ) 399 throws SQLException 400 { 401 structureContents = new TKHashtable(); 402 if( parent != null ) { 403 Enumeration e = parent.structureContents.keys(); 404 while( e.hasMoreElements() ) { 405 Object o = e.nextElement(); 406 structureContents.put( o, parent.structureContents.get( o ) ); 407 } 408 } 409 410 if (docNodeId >= 0) { 412 while (context.siteNodes.getNode (docNodeId) == null) 413 { 414 if( !rs.next() ) { docNodeId = -1; break; } 415 docNodeId = rs.getInt("SITE_NODE_ID"); 416 } 417 } 418 420 while( docNodeId == id ) { 421 int structuredContentId = rs.getInt( "CONTENT_ID" ); 422 SiteContent newContent = 423 context.siteContents.getContent( -structuredContentId ); 424 if( newContent == null ) { 425 426 newContent = 427 new SiteContent( 428 context, 429 -structuredContentId,-1, 430 structuredContentId, 431 rs.getInt( "FORM_ID" ), 432 null, 433 null, 434 true 435 ); 436 } 437 else 438 { 439 cat.warn("KEIN CONTENT!" + newContent.getFormularId() + " , " + rs.getInt("FORM_ID") + ", " + structuredContentId); 440 } 441 structureContents.put( new Integer ( newContent.getFormularId() ), newContent ); 442 if( !rs.next() ) { docNodeId = -1; break; } 443 docNodeId = rs.getInt( "SITE_NODE_ID" ); 444 } 445 446 Enumeration e = childs.elements(); 447 while( e.hasMoreElements() ) { 448 SiteNode child = (SiteNode) e.nextElement(); 449 docNodeId = child.addStructureContents( rs, docNodeId ); 450 } 451 return docNodeId; 452 } 453 454 public void readStructureContents() 455 throws SQLException 456 { 457 TKQuery q = TKWebmanDBManager.newQuery(GenStructureConts.class); 458 q.execute(); 459 ResultSet rs = q.fetchResultSet(); 460 461 if( rs.next() ) { 462 addStructureContents( rs, rs.getInt( "SITE_NODE_ID" ) ); 463 } 464 else { 465 addStructureContents( rs, -1 ); 466 } 467 468 q = TKWebmanDBManager.newQuery(GenSiteDocStructConts.class); 469 q.execute(); 470 rs = q.fetchResultSet(); 471 472 if( rs.next() ) { 473 traverseDocuments( 474 DOC_TRAV_MODE_STRUCT_CONTENT, 475 "SITE_NODE_ID", 476 "SITE_NODE_DOC_IDX", 477 rs, 478 rs.getInt( "SITE_NODE_ID" ), 479 rs.getInt( "SITE_NODE_DOC_IDX" ) 480 ); 481 } 482 } 483 484 public void getContentIntegrations() 485 throws SQLException 486 { 487 TKQuery q = TKWebmanDBManager.newQuery(GenSiteContNodes.class); 488 q.execute(); 489 ResultSet rs = q.fetchResultSet(); 490 491 if( rs.next() ) { 492 traverseDocuments( 493 DOC_TRAV_MODE_CONTENT, 494 "SITE_NODE_ID", 495 "SITE_NODE_DOC_IDX", 496 rs, 497 rs.getInt( "SITE_NODE_ID" ), 498 rs.getInt( "SITE_NODE_DOC_IDX" ) 499 ); 500 } 501 } 502 503 public void expandReferences() 504 { 505 Enumeration e = realDocuments.elements(); 507 while( e.hasMoreElements() ) { 508 SiteDocument doc = (SiteDocument) e.nextElement(); 509 cat.debug("Expanding references for document : " + doc.getShortName()); 510 if( (doc != null) ) { 511 doc.expandReferences(); 512 } 513 } 514 e = childs.elements(); 515 while( e.hasMoreElements() ) { 516 ((SiteNode) e.nextElement()).expandReferences(); 517 } 518 } 519 520 public void findReferenceContentDocuments() 521 { 522 Enumeration e = realDocuments.elements(); 523 while( e.hasMoreElements() ) { 524 SiteDocument doc = (SiteDocument) e.nextElement(); 525 if( (doc != null) && doc.isRefered() ) { 526 doc.findReferenceContentDocuments(); 527 } 528 } 529 e = childs.elements(); 530 while( e.hasMoreElements() ) { 531 ((SiteNode) e.nextElement()).findReferenceContentDocuments(); 532 } 533 } 534 535 public void doContentSelections() 536 { 537 if( type == NODE_TYPE_GROUP && primaryContentSelectionType != null ) { 538 primaryContentSelectionKey = context.integrations.newSelection( 539 primaryContentSelectionType, 540 primaryContentSelectionData, 541 primaryContentNode.getId() 542 ); 543 } 544 545 if (context.siteNodes.isReducedBuild()) return; 547 548 Enumeration e = realDocuments.elements(); 549 while( e.hasMoreElements() ) { 550 SiteDocument doc = (SiteDocument) e.nextElement(); 551 if( doc != null) { 552 doc.doContentSelections(); 553 } 554 } 555 e = childs.elements(); 556 while( e.hasMoreElements() ) { 557 ((SiteNode) e.nextElement()).doContentSelections(); 558 } 559 } 560 561 public int findDistance( SiteNode dest ) 562 { 563 SiteNode node = this; 564 int dist = 0; 565 while( node != dest ) { 566 dist++; 567 node = node.parent; 568 } 569 return dist; 570 } 571 572 public SiteDocument getDocument( String shortName ) 573 { 574 SiteDocument result = (SiteDocument) docNameHash.get( shortName ); 575 if (result != null) 576 return result; 577 578 if (parent != null) 579 return parent.getDocument(shortName); 580 581 return null; 582 } 583 584 public TKVector createGenNodes( GenNode parent ) 585 { 586 if( type == NODE_TYPE_GROUP ) { 587 genNodes = getGroupGenNodes( parent ); 588 } 589 else if( type == NODE_TYPE_SINGLE ) { 590 genNodes = getSingleGenNodes( parent ); 591 } 592 else { 593 throw new Error ( "unexpected node type "+type ); 594 } 595 return genNodes; 596 } 597 598 public GenNode makeGenNode (SiteContent primContent) 600 { 601 602 String genId = "id_"+id+"_pid_"+(primContent == null ? -1 : primContent.getContentId()); 603 GenNode node = context.genNodes.getGenNode(genId); 604 if (node != null) return node; 605 606 boolean old = context.genNodes.isRecursiveBuild(); 607 context.genNodes.setRecursiveBuild(false); 608 609 node = parent != null ? parent.makeGenNode (null) : null; 610 611 if( type == NODE_TYPE_GROUP ) { 612 613 if( primContent == null ) return null; 614 615 String nodeName = primContent.getShortName(); 616 if( nodeName == null ) { nodeName = "id_"+primContent.getContentId(); } 617 node = new GenNode(context,this,node,nodeName,primContent.getName(), realDocuments,primContent,0); 619 context.genNodes.putGenNode(genId,node); 621 622 } else if( type == NODE_TYPE_SINGLE ) 623 { 624 node = new GenNode(context,this,node,shortName,name, realDocuments,null,0); 626 context.genNodes.putGenNode(genId,node); 628 629 } else { 630 throw new Error ( "unexpected node type "+type ); 631 } 632 633 context.genNodes.setRecursiveBuild(old); 634 return node; 635 } 636 637 public TKVector getGroupGenNodes( GenNode parent ) 638 { 639 TKVector primContents; 640 if( primaryContentSelectionKey != null ) { 641 primContents = context.integrations.getSelection( primaryContentSelectionKey ); 642 } 643 else { 644 primContents = primaryContentNode.getContents(); 645 } 646 int size = primContents.size(); 647 if( size == 0 ) return new TKVector(); 648 649 TKVector result = new TKVector( size ); 650 Enumeration e = primContents.elements(); 651 int i=0; 652 while( e.hasMoreElements() ) { 653 SiteContent primContent = (SiteContent) e.nextElement(); 654 if( primContent == null ) { 655 cat.warn( "got null as "+i+".th content of groupnode "+primaryContentNode.getName() ); 656 continue; 657 } 658 String nodeName = primContent.getShortName(); 659 660 if( nodeName == null ) { 661 cat.warn("no shortname for groupcontent "+primContent.getContentId() ); 662 nodeName = "id_"+primContent.getContentId(); 663 } 664 result.addElement( 665 new GenNode( 666 context, 667 this, 668 parent, 669 nodeName, 670 primContent.getName(), 671 realDocuments, 672 primContent, 674 i++ 675 ) 676 ); 677 } 678 return result; 679 } 680 681 public TKVector getSingleGenNodes( GenNode parent ) 682 { 683 TKVector result = new TKVector(); 684 result.addElement( 685 new GenNode( 686 context, 687 this, 688 parent, 689 shortName, 690 name, 691 realDocuments, 692 null, 694 0 695 ) 696 ); 697 return result; 698 } 699 700 public TKVector getSubGenNodes( GenNode parent ) 701 { 702 TKVector result = new TKVector(); 703 Enumeration e = childs.elements(); 704 while( e.hasMoreElements() ) { 705 result.concat( ((SiteNode) e.nextElement()).createGenNodes( parent ) ); 706 } 707 return result; 708 } 709 710 public void complete () { 712 713 if (isComplete) return; 714 isComplete = true; 715 716 if (parent != null) parent.complete(); 717 718 doContentSelections (); 719 } 720 722 723 public void accept(SiteTreeVisitor visitor) throws Exception 724 { 725 visitor.visitSiteNode(this); 726 for (int i = 0; i < documents.size(); ++i) 727 { 728 SiteDocument doc = (SiteDocument) documents.elementAt(i); 729 if (doc != null) 730 { 731 doc.accept(visitor); 732 } 733 } 734 for (int i = 0; i < childs.size(); ++i) 735 { 736 ((SiteNode) childs.elementAt(i)).accept(visitor); 737 } 738 } 739 740 752 public void assignInheritableDocuments() 753 { 754 InheritableDocumentsManager docMan = new InheritableDocumentsManager(); 755 assignInheritableDocuments(docMan); 756 } 757 758 763 private void assignInheritableDocuments(InheritableDocumentsManager docMan) 764 { 765 docMan.descend(); 766 Enumeration docs = documents.elements(); 767 while (docs.hasMoreElements()) { 768 docMan.addDocument((SiteDocument) docs.nextElement()); 769 } 770 771 Enumeration validDocs = docMan.getValidDocuments(); 772 while (validDocs.hasMoreElements()) { 773 SiteDocument doc = (SiteDocument) validDocs.nextElement(); 774 775 if (doc.isInheritable()) { 776 SiteDocument resultDoc = null; 777 if (doc.getAnchor() == this) { 778 resultDoc = doc; 780 if (doc.getInheritStartLevel() == 0) 781 { 782 realDocuments.addElement(resultDoc); 783 } 784 } 785 else 786 { 787 int newInheritStartLevel = doc.getInheritStartLevel() 788 + doc.getAnchor().getLevel() - getLevel(); 789 if (newInheritStartLevel < 0) 790 newInheritStartLevel = 0; 791 792 int newInheritStopLevel; 793 if (doc.getInheritStopLevel() == -1) { newInheritStopLevel = -1; 795 } 796 else { 797 newInheritStopLevel = doc.getInheritStopLevel() 798 + doc.getAnchor().getLevel() - getLevel(); 799 } 800 resultDoc = new SiteDocument(context, doc, this, documents.size(), 801 newInheritStartLevel , newInheritStopLevel); 802 documents.addElement( resultDoc ); if (resultDoc.getInheritStartLevel() == 0) 804 { 805 realDocuments.addElement(resultDoc); 806 } 807 808 } 809 docNameHash.put( resultDoc.getShortName(), resultDoc ); 810 } 812 else 813 { 814 docNameHash.put( doc.getShortName(), doc ); 815 realDocuments.addElement(doc); 816 } 817 } 818 819 Enumeration e = childs.elements(); 821 while( e.hasMoreElements() ) { 822 SiteNode child = (SiteNode) e.nextElement(); 823 child.assignInheritableDocuments(docMan); 824 } 825 docMan.ascend(); 826 } 827 } 828 829 846 class InheritableDocumentsManager 847 { 848 private Vector docVectors; private Vector curValidDocs; private int curLevel; 852 InheritableDocumentsManager() 853 { 854 setDocVectorSize(3); 855 curLevel = -1; 856 curValidDocs = new Vector(); 857 } 858 859 863 void descend() 864 { 865 Vector prevDocs = getDocs(curLevel); 866 Vector nextDocs = getDocs(curLevel+1); 867 nextDocs.setSize(0); 868 if (prevDocs != null) { 869 for (int i = 0; i < prevDocs.size(); ++i) { 870 SiteDocument doc = (SiteDocument) prevDocs.elementAt(i); 871 int classification = doc.classifyByLevel(curLevel + 1); 872 if (classification <= 0) { 873 nextDocs.addElement(doc); 874 } 875 } 876 } 877 ++curLevel; 878 879 findValidDocs(); 880 } 881 882 885 void ascend() 886 { 887 if (curLevel == 0) 888 return; 890 --curLevel; 891 892 findValidDocs(); 893 } 894 895 901 void addDocument(SiteDocument doc) 902 { 903 if (doc == null) 904 return; 905 906 int classification = doc.classifyByLevel(curLevel); 907 if (classification <= 0) { 908 Vector docs = getDocs(curLevel); 909 for (int i = 0; i < docs.size(); i++) 910 { 911 SiteDocument curDoc = (SiteDocument)docs.elementAt(i); 912 if (curDoc.getShortName().equals(doc.getShortName())) 913 docs.removeElementAt(i); 914 } 915 for (int i = 0; i < curValidDocs.size(); i++) 916 { 917 SiteDocument curDoc = (SiteDocument)curValidDocs.elementAt(i); 918 if (curDoc.getShortName().equals(doc.getShortName())) 919 curValidDocs.removeElementAt(i); 920 } 921 docs.addElement(doc); 922 } 923 if (classification == 0) { 924 925 curValidDocs.addElement(doc); 926 } 927 } 928 929 932 Enumeration getValidDocuments() 933 { 934 return curValidDocs.elements(); 935 } 936 937 940 int getCurrentLevel() 941 { 942 return curLevel; 943 } 944 945 private void findValidDocs() 946 { 947 Vector docs = getDocs(curLevel); 948 949 curValidDocs.setSize(0); 950 for (int i = 0; i < docs.size(); ++i) { 951 SiteDocument doc = (SiteDocument) docs.elementAt(i); 952 if (doc.classifyByLevel(curLevel) == 0) { 953 curValidDocs.addElement(doc); 954 } 955 } 956 } 957 958 private Vector getDocs(int index) 959 { 960 if (index >= docVectors.size()) { 961 setDocVectorSize(index + 1); 962 } 963 964 Vector docs; 965 try { 966 docs = (Vector) docVectors.elementAt(index); 967 } 968 catch (ArrayIndexOutOfBoundsException e) { 969 return null; } 971 972 return docs; 973 } 974 975 976 private void setDocVectorSize(int size) 977 { 978 int prevSize = (docVectors == null) ? 0 : docVectors.size(); 979 if (size > prevSize) { 980 if (docVectors == null) { 981 docVectors = new Vector(size); 982 } 983 docVectors.setSize(size); 984 for (int i = prevSize; i < size; ++i) { 985 docVectors.setElementAt(new Vector(), i); 986 } 987 } 988 } 989 990 } 991 | Popular Tags |