You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StandardStructureTypes.java 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. import java.io.Serializable;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. /**
  23. * Standard structure types, as defined in section 10.7.4 of the PDF Reference, Fourth Edition (PDF 1.5).
  24. */
  25. public final class StandardStructureTypes {
  26. public static final class Grouping {
  27. public static final StructureType DOCUMENT = new StructureTypeImpl("Document");
  28. public static final StructureType PART = new StructureTypeImpl("Part");
  29. public static final StructureType ART = new StructureTypeImpl("Art");
  30. public static final StructureType SECT = new StructureTypeImpl("Sect");
  31. public static final StructureType DIV = new StructureTypeImpl("Div");
  32. public static final StructureType BLOCK_QUOTE = new StructureTypeImpl("BlockQuote");
  33. public static final StructureType CAPTION = new StructureTypeImpl("Caption");
  34. public static final StructureType TOC = new StructureTypeImpl("TOC");
  35. public static final StructureType TOCI = new StructureTypeImpl("TOCI");
  36. public static final StructureType INDEX = new StructureTypeImpl("Index");
  37. public static final StructureType NON_STRUCT = new StructureTypeImpl("NonStruct");
  38. public static final StructureType PRIVATE = new StructureTypeImpl("Private");
  39. }
  40. public static final class Paragraphlike {
  41. public static final StructureType H = new StructureTypeImpl("H");
  42. public static final StructureType H1 = new StructureTypeImpl("H1");
  43. public static final StructureType H2 = new StructureTypeImpl("H2");
  44. public static final StructureType H3 = new StructureTypeImpl("H3");
  45. public static final StructureType H4 = new StructureTypeImpl("H4");
  46. public static final StructureType H5 = new StructureTypeImpl("H5");
  47. public static final StructureType H6 = new StructureTypeImpl("H6");
  48. public static final StructureType P = new StructureTypeImpl("P");
  49. }
  50. public static final class List {
  51. public static final StructureType L = new StructureTypeImpl("L");
  52. public static final StructureType LI = new StructureTypeImpl("LI");
  53. public static final StructureType LBL = new StructureTypeImpl("Lbl");
  54. public static final StructureType LBODY = new StructureTypeImpl("LBody");
  55. }
  56. public static final class Table {
  57. public static final StructureType TABLE = new StructureTypeImpl("Table");
  58. public static final StructureType TR = new StructureTypeImpl("TR");
  59. public static final StructureType TH = new StructureTypeImpl("TH");
  60. public static final StructureType TD = new StructureTypeImpl("TD");
  61. public static final StructureType THEAD = new StructureTypeImpl("THead");
  62. public static final StructureType TBODY = new StructureTypeImpl("TBody");
  63. public static final StructureType TFOOT = new StructureTypeImpl("TFoot");
  64. }
  65. public static final class InlineLevelStructure {
  66. public static final StructureType SPAN = new StructureTypeImpl("Span");
  67. public static final StructureType QUOTE = new StructureTypeImpl("Quote");
  68. public static final StructureType NOTE = new StructureTypeImpl("Note");
  69. public static final StructureType REFERENCE = new StructureTypeImpl("Reference");
  70. public static final StructureType BIB_ENTRY = new StructureTypeImpl("BibEntry");
  71. public static final StructureType CODE = new StructureTypeImpl("Code");
  72. public static final StructureType LINK = new StructureTypeImpl("Link");
  73. public static final StructureType ANNOT = new StructureTypeImpl("Annot");
  74. }
  75. public static final class RubyOrWarichu {
  76. public static final StructureType RUBY = new StructureTypeImpl("Ruby");
  77. public static final StructureType RB = new StructureTypeImpl("RB");
  78. public static final StructureType RT = new StructureTypeImpl("RT");
  79. public static final StructureType RP = new StructureTypeImpl("RP");
  80. public static final StructureType WARICHU = new StructureTypeImpl("Warichu");
  81. public static final StructureType WT = new StructureTypeImpl("WT");
  82. public static final StructureType WP = new StructureTypeImpl("WP");
  83. }
  84. public static final class Illustration {
  85. public static final StructureType FIGURE = new StructureTypeImpl("Figure");
  86. public static final StructureType FORMULA = new StructureTypeImpl("Formula");
  87. public static final StructureType FORM = new StructureTypeImpl("Form");
  88. }
  89. private static class StructureTypeImpl implements StructureType, Serializable {
  90. private static final long serialVersionUID = 8577475043360334210L;
  91. private final PDFName name;
  92. protected StructureTypeImpl(String name) {
  93. this.name = new PDFName(name);
  94. StandardStructureTypes.STRUCTURE_TYPES.put(name, this);
  95. }
  96. public PDFName getName() {
  97. return name;
  98. }
  99. @Override
  100. public String toString() {
  101. return name.toString().substring(1);
  102. }
  103. }
  104. private static final Map<String, StructureType> STRUCTURE_TYPES = new HashMap<String, StructureType>();
  105. private StandardStructureTypes() { }
  106. /**
  107. * Returns the standard structure type of the given name.
  108. *
  109. * @param name the name of a structure type, case sensitive. For example, Document,
  110. * Sect, H1, etc.
  111. * @return the corresponding {@code StructureType} instance, or {@code null} if the given
  112. * name does not correspond to a standard structure type
  113. */
  114. public static StructureType get(String name) {
  115. return STRUCTURE_TYPES.get(name);
  116. }
  117. }