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 18 /* $Id$ */ 19 20 package org.apache.fop.render.pdf.extensions; 21 22 // CSOFF: LineLengthCheck 23 24 /** 25 * Enumeration type for PDF dictionary extension elements. 26 */ 27 public enum PDFDictionaryType { 28 Action("action", true), // action dictionary element 29 Catalog("catalog"), // catalog dictionary element 30 Dictionary("dictionary"), // generic (nested) dictionary element 31 Layer("layer", true), // optional content group dictionary element 32 Navigator("navigator", true), // navigation node dictionary element 33 Page("page"), // page dictionary element 34 /** Document Information Dictionary */ 35 Info("info"), 36 VT("vt"), 37 PagePiece("pagepiece"); 38 39 private String elementName; 40 private boolean usesIDAttribute; PDFDictionaryType(String elementName, boolean usesIDAttribute)41 PDFDictionaryType(String elementName, boolean usesIDAttribute) { 42 this.elementName = elementName; 43 this.usesIDAttribute = usesIDAttribute; 44 } PDFDictionaryType(String elementName)45 PDFDictionaryType(String elementName) { 46 this(elementName, false); 47 } elementName()48 public String elementName() { 49 return elementName; 50 } usesIDAttribute()51 public boolean usesIDAttribute() { 52 return usesIDAttribute; 53 } valueOfElementName(String elementName)54 static PDFDictionaryType valueOfElementName(String elementName) { 55 for (PDFDictionaryType type : values()) { 56 if (type.elementName.equals(elementName)) { 57 return type; 58 } 59 } 60 throw new IllegalArgumentException(); 61 } hasValueOfElementName(String elementName)62 static boolean hasValueOfElementName(String elementName) { 63 try { 64 return valueOfElementName(elementName) != null; 65 } catch (Exception e) { 66 return false; 67 } 68 } 69 } 70