KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > bytes > filters > Filter


1 /*
2   Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright © 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.bytes.filters;
28
29 import it.stefanochizzolini.clown.objects.PdfName;
30 import it.stefanochizzolini.clown.util.NotImplementedException;
31
32 /**
33   Abstract filter [PDF:1.6:3.3].
34
35   @author Stefano Chizzolini
36   @version 0.0.2, 12/19/06
37   @since 0.0.2
38 */

39 public abstract class Filter
40 {
41   // <class>
42
// <static>
43
// <fields>
44
private static final Filter FlateDecode = new FlateFilter();
45   // </fields>
46

47   // <interface>
48
// <public>
49
/**
50     Gets a specific filter object.
51     @param name Name of the requested filter.
52     @return Filter object associated to the name.
53   */

54   public static Filter get(
55     PdfName name
56     )
57   {
58     /*
59       NOTE: This is a factory singleton method for any filter-derived object.
60     */

61     if(name == null)
62       return null;
63
64     if(name.equals(PdfName.FlateDecode)
65       || name.equals(PdfName.Fl))
66       return FlateDecode;
67     else if(name.equals(PdfName.LZWDecode)
68       || name.equals(PdfName.LZW))
69       throw new NotImplementedException("LZWDecode");
70     else if(name.equals(PdfName.ASCIIHexDecode)
71       || name.equals(PdfName.AHx))
72       throw new NotImplementedException("ASCIIHexDecode");
73     else if(name.equals(PdfName.ASCII85Decode)
74       || name.equals(PdfName.A85))
75       throw new NotImplementedException("ASCII85Decode");
76     else if(name.equals(PdfName.RunLengthDecode)
77       || name.equals(PdfName.RL))
78       throw new NotImplementedException("RunLengthDecode");
79     else if(name.equals(PdfName.CCITTFaxDecode)
80       || name.equals(PdfName.CCF))
81       throw new NotImplementedException("CCITTFaxDecode");
82     else if(name.equals(PdfName.JBIG2Decode))
83       throw new NotImplementedException("JBIG2Decode");
84     else if(name.equals(PdfName.DCTDecode)
85       || name.equals(PdfName.DCT))
86       throw new NotImplementedException("DCTDecode");
87     else if(name.equals(PdfName.JPXDecode))
88       throw new NotImplementedException("JPXDecode");
89     else if(name.equals(PdfName.Crypt))
90       throw new NotImplementedException("Crypt");
91
92     return null;
93   }
94   // </public>
95
// </interface>
96
// </static>
97

98   // <dynamic>
99
// <constructors>
100
protected Filter(
101     )
102   {}
103   // </constructors>
104

105   // <interface>
106
// <public>
107
public abstract byte[] decode(
108     byte[] data,
109     int offset,
110     int length
111     );
112
113   public abstract byte[] encode(
114     byte[] data,
115     int offset,
116     int length
117     );
118   // </public>
119
// </interface>
120
// </dynamic>
121
// </class>
122
}
Popular Tags