Mercurial > hg > digilib-old
annotate servlet/src/digilib/servlet/PDFJobInformation.java @ 505:06d7e8c09b11 digilibPDF
*** empty log message ***
author | cmielack |
---|---|
date | Fri, 06 Mar 2009 11:08:26 +0100 |
parents | fdb824bd57ab |
children | ab94692bff0c |
rev | line source |
---|---|
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
1 package digilib.servlet; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
2 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
3 import java.util.ArrayList; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
4 import java.util.regex.Matcher; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
5 import java.util.regex.Pattern; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
6 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
7 import javax.servlet.http.HttpServletRequest; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
8 |
505 | 9 import org.apache.log4j.Logger; |
10 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
11 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
12 /** |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
13 * A container class for storing a set of instructional parameters |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
14 * used for content generating classes like MakePDF. |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
15 * |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
16 * |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
17 * @author cmielack |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
18 * |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
19 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
20 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
21 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
22 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
23 public class PDFJobInformation extends ParameterMap { |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
24 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
25 String[] parameter_list = {"pgs"};//{"fn","pgs","dw","dh"}; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
26 /*, |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
27 "wx", "wy", "ww", "wh", "ws", |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
28 "mo", "rot", "cont", "brgt", "rgbm", "rbgm", |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
29 "ddpi", "ddpix", "ddpiy", "scale"};*/ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
30 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
31 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
32 ImageJobInformation image_info = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
33 DigilibConfiguration dlConfig = null; |
505 | 34 /** gengeral logger for this class */ |
35 protected static Logger logger = Logger.getLogger("digilib.servlet"); | |
36 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
37 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
38 public PDFJobInformation(DigilibConfiguration dlcfg) { |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
39 super(30); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
40 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
41 // url of the page/document (second part) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
42 // newParameter("fn", "", null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
43 // page number |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
44 newParameter("pgs", "", null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
45 // width of client in pixels |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
46 // newParameter("dw", new Integer(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
47 // height of client in pixels |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
48 // newParameter("dh", new Integer(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
49 // left edge of image (float from 0 to 1) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
50 /* newParameter("wx", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
51 // top edge in image (float from 0 to 1) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
52 newParameter("wy", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
53 // width of image (float from 0 to 1) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
54 newParameter("ww", new Float(1), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
55 // height of image (float from 0 to 1) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
56 newParameter("wh", new Float(1), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
57 // scale factor |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
58 newParameter("ws", new Float(1), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
59 // special options like 'fit' for gifs |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
60 newParameter("mo", "", null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
61 // rotation angle (degree) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
62 newParameter("rot", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
63 // contrast enhancement factor |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
64 newParameter("cont", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
65 // brightness enhancement factor |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
66 newParameter("brgt", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
67 // color multiplicative factors |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
68 newParameter("rgbm", "0/0/0", null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
69 // color additive factors |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
70 newParameter("rgba", "0/0/0", null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
71 // display dpi resolution (total) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
72 newParameter("ddpi", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
73 // display dpi X resolution |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
74 newParameter("ddpix", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
75 // display dpi Y resolution |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
76 newParameter("ddpiy", new Float(0), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
77 // scale factor for mo=ascale |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
78 newParameter("scale", new Float(1), null, 's'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
79 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
80 /* |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
81 * Parameters of type 'i' are not exchanged between client and server, |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
82 * but are for the servlets or JSPs internal use. |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
83 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
84 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
85 /* // url of the page/document (first part, may be empty) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
86 newParameter("request.path", "", null, 'i'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
87 // base URL (from http:// to below /servlet) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
88 newParameter("base.url", null, null, 'i'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
89 // DocuImage instance for this request |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
90 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
91 /* |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
92 * Parameters of type 'c' are for the clients use |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
93 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
94 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
95 /* // "real" filename |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
96 newParameter("img.fn", "", null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
97 // image dpi x |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
98 newParameter("img.dpix", new Integer(0), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
99 // image dpi y |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
100 newParameter("img.dpiy", new Integer(0), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
101 // hires image size x |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
102 newParameter("img.pix_x", new Integer(0), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
103 // hires image size y |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
104 newParameter("img.pix_y", new Integer(0), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
105 // total number of pages |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
106 newParameter("pt", new Integer(0), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
107 // display level of digilib (0 = just image, 1 = one HTML page |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
108 // 2 = in frameset, 3 = XUL-'frameset' |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
109 // 4 = XUL-Sidebar ) |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
110 newParameter("lv", new Integer(2), null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
111 // marks |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
112 newParameter("mk", "", null, 'c'); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
113 */ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
114 dlConfig = dlcfg; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
115 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
116 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
117 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
118 public void setWithRequest(HttpServletRequest request) { |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
119 image_info = new ImageJobInformation(dlConfig); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
120 image_info.setWithRequest(request); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
121 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
122 for (String param : parameter_list){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
123 if (request.getParameterMap().containsKey(param)){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
124 setValueFromString(param, request.getParameter(param)); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
125 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
126 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
127 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
128 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
129 public String getDocumentId(){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
130 String id; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
131 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
132 // TODO use complete request information for id generation |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
133 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
134 if(this.image_info!=null){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
135 String fn = image_info.getAsString("fn"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
136 String dh = image_info.getAsString("dh"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
137 String pgs = getAsString("pgs"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
138 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
139 id = "fn=" + fn + "&dh=" + dh + "&pgs=" + pgs + ".pdf"; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
140 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
141 else { |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
142 id = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
143 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
144 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
145 return id; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
146 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
147 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
148 public ImageJobInformation getImageJobInformation(){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
149 ImageJobInformation new_image_info = (ImageJobInformation) image_info.clone(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
150 return new_image_info; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
151 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
152 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
153 public Integer[] getPageNrs() throws Exception{ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
154 ArrayList<Integer> pgs=new ArrayList<Integer>(); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
155 Integer[] numarray = null; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
156 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
157 String intervals[] = getAsString("pgs").split(","); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
158 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
159 // convert the page-interval-strings into a list containing every single page |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
160 for(String interval: intervals){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
161 if(interval.indexOf("-") > 1){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
162 String nums[] = interval.split("-"); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
163 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
164 // if(nums.length!=2){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
165 // throw new Exception("Malformed pageset expression: "+getAsString("pgs")); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
166 // } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
167 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
168 for(int i=Integer.valueOf(nums[0]); i <= Integer.valueOf(nums[1]); i++){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
169 pgs.add(i); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
170 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
171 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
172 else if (interval.indexOf("-") < 0){ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
173 pgs.add(Integer.valueOf(interval)); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
174 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
175 // else{ |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
176 // throw new Exception("Malformed pageset expression: "+getAsString("pgs")); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
177 // } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
178 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
179 |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
180 pgs.toArray(numarray); |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
181 return numarray; |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
182 } |
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
183 |
505 | 184 |
185 public boolean checkValidity(){ | |
186 String pgs = getAsString("pgs"); | |
187 try{ | |
188 String[] intervals = null; | |
189 if(pgs.indexOf(",")>0){ | |
190 intervals = pgs.split(","); | |
191 } | |
192 else{ | |
193 intervals = new String[1]; | |
194 intervals[0]=pgs; | |
195 } | |
196 for(String interval:intervals){ | |
197 if(interval.indexOf("-")>=0){ | |
198 String[] intrvl = interval.split("-"); | |
199 int a = Integer.valueOf(intrvl[0]); | |
200 int b = Integer.valueOf(intrvl[1]); | |
201 if(a<=0 || b<a){ | |
202 return false; | |
203 } | |
204 } | |
205 else { | |
206 int c = Integer.valueOf(interval); | |
207 if(c<=0) | |
208 return false; | |
209 | |
210 } | |
211 } | |
212 } | |
213 catch(Exception e){ | |
214 logger.error("invalid pgs-input"); | |
215 return false; | |
216 } | |
217 return true; | |
218 } | |
219 | |
503
fdb824bd57ab
first functional version of PDFCache after restructuring the code
cmielack
parents:
diff
changeset
|
220 } |