1 31 package org.pdfbox.util; 32 33 import java.util.Collections ; 34 import java.util.HashMap ; 35 import java.util.Map ; 36 37 43 public class PDFOperator 44 { 45 private String theOperator; 46 private byte[] imageData; 47 private ImageParameters imageParameters; 48 49 private static Map operators = Collections.synchronizedMap( new HashMap () ); 50 51 56 private PDFOperator( String aOperator ) 57 { 58 theOperator = aOperator; 59 if( aOperator.startsWith( "/" ) ) 60 { 61 throw new RuntimeException ( "Operators are not allowed to start with / '" + aOperator + "'" ); 62 } 63 } 64 65 72 public static PDFOperator getOperator( String operator ) 73 { 74 PDFOperator operation = null; 75 if( operator.equals( "ID" ) || operator.equals( "BI" ) ) 76 { 77 operation = new PDFOperator( operator ); 79 } 80 else 81 { 82 operation = (PDFOperator)operators.get( operator ); 83 if( operation == null ) 84 { 85 operation = new PDFOperator( operator ); 86 operators.put( operator, operation ); 87 } 88 } 89 90 return operation; 91 } 92 93 98 public String getOperation() 99 { 100 return theOperator; 101 } 102 103 108 public String toString() 109 { 110 return "PDFOperator{" + theOperator + "}"; 111 } 112 113 119 public byte[] getImageData() 120 { 121 return this.imageData; 122 } 123 124 129 public void setImageData(byte[] imageDataArray) 130 { 131 imageData = imageDataArray; 132 } 133 134 139 public ImageParameters getImageParameters() 140 { 141 return imageParameters; 142 } 143 144 149 public void setImageParameters( ImageParameters params) 150 { 151 imageParameters = params; 152 } 153 } | Popular Tags |