1 25 package com.catcode.odf; 26 27 import java.lang.reflect.Field ; 28 import java.lang.reflect.Modifier ; 29 30 import java.text.DateFormat ; 31 import java.text.ParseException ; 32 import java.text.SimpleDateFormat ; 33 34 import java.util.Date ; 35 import java.util.GregorianCalendar ; 36 import java.util.Hashtable ; 37 38 54 55 public class OpenDocumentMetadata 56 { 57 private String generator; private String title; private String description; private String subject; private String keyword; private String initialCreator; private String creator; private String printedBy; private Date creationDate; private Date date; private Date printDate; private String language; private Integer editingCycles; private Duration editingDuration; 72 private Integer pageCount; private Integer tableCount; private Integer drawCount; private Integer imageCount; private Integer oleObjectCount; private Integer paragraphCount; private Integer wordCount; private Integer characterCount; private Integer frameCount; private Integer sentenceCount; private Integer syllableCount; private Integer nonWhitespaceCharacterCount; 85 private Integer rowCount; private Integer cellCount; private Integer objectCount; 90 private static final SimpleDateFormat isoDate = new 91 SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss"); 92 93 protected Hashtable userDefined = new Hashtable (10); 94 95 100 public String getGenerator() 101 { 102 return this.generator; 103 } 104 105 111 public void setGenerator(String generator) 112 { 113 this.generator = generator; 114 } 115 116 121 public String getTitle() 122 { 123 return this.title; 124 } 125 126 132 public void setTitle(String title) 133 { 134 this.title = title; 135 } 136 137 142 public String getDescription() 143 { 144 return this.description; 145 } 146 147 153 public void setDescription(String description) 154 { 155 this.description = description; 156 } 157 158 163 public String getSubject() 164 { 165 return this.subject; 166 } 167 168 174 public void setSubject(String subject) 175 { 176 this.subject = subject; 177 } 178 179 184 public String getKeyword() 185 { 186 return this.keyword; 187 } 188 189 195 public void setKeyword(String keyword) 196 { 197 this.keyword = keyword; 198 } 199 200 205 public String getInitialCreator() 206 { 207 return this.initialCreator; 208 } 209 210 216 public void setInitialCreator(String initialCreator) 217 { 218 this.initialCreator = initialCreator; 219 } 220 221 226 public String getCreator() 227 { 228 return this.creator; 229 } 230 231 238 public void setCreator(String creator) 239 { 240 this.creator = creator; 241 } 242 243 248 public String getPrintedBy() 249 { 250 return this.printedBy; 251 } 252 253 259 public void setPrintedBy(String printedBy) 260 { 261 this.printedBy = printedBy; 262 } 263 264 270 public Date getCreationDate() 271 { 272 return this.creationDate; 273 } 274 275 281 public void setCreationDate(Date creationDate) 282 { 283 this.creationDate = creationDate; 284 } 285 286 293 public void setCreationDate( String strCreationDate ) 294 { 295 try 296 { 297 creationDate = isoDate.parse( strCreationDate ); 298 } 299 catch (ParseException e) 300 { 301 creationDate = null; 302 } 303 } 304 305 311 public Date getDate() 312 { 313 return this.date; 314 } 315 316 322 public void setDate(Date date) 323 { 324 this.date = date; 325 } 326 327 334 public void setDate(String strDate ) 335 { 336 try 337 { 338 date = isoDate.parse( strDate ); 339 } 340 catch (ParseException e) 341 { 342 date = null; 343 } 344 } 345 346 352 public Date getPrintDate() 353 { 354 return this.printDate; 355 } 356 357 363 public void setPrintDate(Date printDate) 364 { 365 this.printDate = printDate; 366 } 367 368 375 public void setPrintDate( String strPrintDate ) 376 { 377 try 378 { 379 printDate = isoDate.parse( strPrintDate ); 380 } 381 catch (ParseException e) 382 { 383 printDate = null; 384 } 385 } 386 387 396 public String getLanguage() 397 { 398 return this.language; 399 } 400 401 408 public void setLanguage(String language) 409 { 410 this.language = language; 411 } 412 413 418 public int getEditingCycles() 419 { 420 return this.editingCycles.intValue(); 421 } 422 423 429 public void setEditingCycles(int editingCycles) 430 { 431 this.editingCycles = new Integer (editingCycles); 432 } 433 434 440 public void setEditingCycles(String strEditingCycles) 441 { 442 this.editingCycles = new Integer ( strEditingCycles ); 443 } 444 445 451 public Duration getEditingDuration() 452 { 453 return this.editingDuration; 454 } 455 456 462 public void setEditingDuration(Duration editingDuration) 463 { 464 this.editingDuration = editingDuration; 465 } 466 467 474 public void setEditingDuration(String strEditingDuration) 475 { 476 this.editingDuration = Duration.parseDuration( strEditingDuration ); 477 } 478 479 484 public int getPageCount() 485 { 486 return this.pageCount.intValue(); 487 } 488 489 495 public void setPageCount(int pageCount) 496 { 497 this.pageCount = new Integer (pageCount); 498 } 499 500 505 public int getTableCount() 506 { 507 return this.tableCount.intValue(); 508 } 509 510 516 public void setTableCount(int tableCount) 517 { 518 this.tableCount = new Integer (tableCount); 519 } 520 521 526 public int getDrawCount() 527 { 528 return this.drawCount.intValue(); 529 } 530 531 537 public void setDrawCount(int drawCount) 538 { 539 this.drawCount = new Integer (drawCount); 540 } 541 542 547 public int getImageCount() 548 { 549 return this.imageCount.intValue(); 550 } 551 552 558 public void setImageCount(int imageCount) 559 { 560 this.imageCount = new Integer (imageCount); 561 } 562 563 568 public int getOleObjectCount() 569 { 570 return this.oleObjectCount.intValue(); 571 } 572 573 579 public void setOleObjectCount(int oleObjectCount) 580 { 581 this.oleObjectCount = new Integer (oleObjectCount); 582 } 583 584 589 public int getParagraphCount() 590 { 591 return this.paragraphCount.intValue(); 592 } 593 594 600 public void setParagraphCount(int paragraphCount) 601 { 602 this.paragraphCount = new Integer (paragraphCount); 603 } 604 605 610 public int getWordCount() 611 { 612 return this.wordCount.intValue(); 613 } 614 615 621 public void setWordCount(int wordCount) 622 { 623 this.wordCount = new Integer (wordCount); 624 } 625 626 631 public int getCharacterCount() 632 { 633 return this.characterCount.intValue(); 634 } 635 636 642 public void setCharacterCount(int characterCount) 643 { 644 this.characterCount = new Integer (characterCount); 645 } 646 647 652 public int getFrameCount() 653 { 654 return this.frameCount.intValue(); 655 } 656 657 663 public void setFrameCount(int frameCount) 664 { 665 this.frameCount = new Integer (frameCount); 666 } 667 668 673 public int getSentenceCount() 674 { 675 return this.sentenceCount.intValue(); 676 } 677 678 684 public void setSentenceCount(int sentenceCount) 685 { 686 this.sentenceCount = new Integer (sentenceCount); 687 } 688 689 694 public int getSyllableCount() 695 { 696 return this.syllableCount.intValue(); 697 } 698 699 705 public void setSyllableCount(int syllableCount) 706 { 707 this.syllableCount = new Integer (syllableCount); 708 } 709 710 715 public int getNonWhitespaceCharacterCount() 716 { 717 return this.nonWhitespaceCharacterCount.intValue(); 718 } 719 720 727 public void setNonWhitespaceCharacterCount(int nonWhitespaceCharacterCount) 728 { 729 this.nonWhitespaceCharacterCount = new Integer ( 730 nonWhitespaceCharacterCount); 731 } 732 733 739 public int getRowCount() 740 { 741 return this.rowCount.intValue(); 742 } 743 744 750 public void setRowCount(int rowCount) 751 { 752 this.rowCount = new Integer (rowCount); 753 } 754 755 760 public int getCellCount() 761 { 762 return this.cellCount.intValue(); 763 } 764 765 771 public void setCellCount(int cellCount) 772 { 773 this.cellCount = new Integer (cellCount); 774 } 775 776 782 public int getObjectCount() 783 { 784 return this.objectCount.intValue(); 785 } 786 787 793 public void setObjectCount(int objectCount) 794 { 795 this.objectCount = new Integer (objectCount); 796 } 797 798 808 public Hashtable getUserDefined() 809 { 810 return this.userDefined; 811 } 812 813 819 public void setUserDefined(Hashtable userDefined) 820 { 821 this.userDefined = userDefined; 822 } 823 824 830 public void setUserDefined( String name, int value ) 831 { 832 userDefined.put( name, new Double ( value ) ); 833 } 834 835 841 public void setUserDefined( String name, double value ) 842 { 843 userDefined.put( name, new Double ( value ) ); 844 } 845 846 852 public void setUserDefined( String name, boolean value ) 853 { 854 userDefined.put( name, new Boolean ( value ) ); 855 } 856 857 865 public void setUserDefined( String name, Object value ) 866 { 867 userDefined.put( name, value ); 868 } 869 870 875 public Object getFieldByName( String fieldName ) 876 { 877 Field theField; 878 Object result = null; 879 try 880 { 881 theField = OpenDocumentMetadata.class.getDeclaredField( fieldName ); 882 result = theField.get(this); 883 } 884 catch (Exception e) 885 { 886 } 888 return result; 889 } 890 891 901 public String toString() 902 { 903 Field [] field = OpenDocumentMetadata.class.getDeclaredFields(); 904 int i; 905 String result =""; 906 String oneField; 907 908 for (i=0; i < field.length; i++) 909 { 910 if (!Modifier.isStatic(field[i].getModifiers()) ) 911 { 912 try 913 { 914 if (field[i].get(this) != null) 915 { 916 oneField = field[i].get(this).toString(); 917 } 918 else 919 { 920 oneField = "null"; 921 } 922 } 923 catch (IllegalAccessException e) 924 { 925 oneField = "**cannot access**"; 926 } 927 result += field[i].getName() + ": " + 928 oneField + "\n"; 929 } 930 } 931 return result; 932 } 933 934 } 935 936 | Popular Tags |