001: /*
002: Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.bytes.filters;
028:
029: import it.stefanochizzolini.clown.objects.PdfName;
030: import it.stefanochizzolini.clown.util.NotImplementedException;
031:
032: /**
033: Abstract filter [PDF:1.6:3.3].
034:
035: @author Stefano Chizzolini
036: @version 0.0.2, 12/19/06
037: @since 0.0.2
038: */
039: public abstract class Filter {
040: // <class>
041: // <static>
042: // <fields>
043: private static final Filter FlateDecode = new FlateFilter();
044:
045: // </fields>
046:
047: // <interface>
048: // <public>
049: /**
050: Gets a specific filter object.
051: @param name Name of the requested filter.
052: @return Filter object associated to the name.
053: */
054: public static Filter get(PdfName name) {
055: /*
056: NOTE: This is a factory singleton method for any filter-derived object.
057: */
058: if (name == null)
059: return null;
060:
061: if (name.equals(PdfName.FlateDecode) || name.equals(PdfName.Fl))
062: return FlateDecode;
063: else if (name.equals(PdfName.LZWDecode)
064: || name.equals(PdfName.LZW))
065: throw new NotImplementedException("LZWDecode");
066: else if (name.equals(PdfName.ASCIIHexDecode)
067: || name.equals(PdfName.AHx))
068: throw new NotImplementedException("ASCIIHexDecode");
069: else if (name.equals(PdfName.ASCII85Decode)
070: || name.equals(PdfName.A85))
071: throw new NotImplementedException("ASCII85Decode");
072: else if (name.equals(PdfName.RunLengthDecode)
073: || name.equals(PdfName.RL))
074: throw new NotImplementedException("RunLengthDecode");
075: else if (name.equals(PdfName.CCITTFaxDecode)
076: || name.equals(PdfName.CCF))
077: throw new NotImplementedException("CCITTFaxDecode");
078: else if (name.equals(PdfName.JBIG2Decode))
079: throw new NotImplementedException("JBIG2Decode");
080: else if (name.equals(PdfName.DCTDecode)
081: || name.equals(PdfName.DCT))
082: throw new NotImplementedException("DCTDecode");
083: else if (name.equals(PdfName.JPXDecode))
084: throw new NotImplementedException("JPXDecode");
085: else if (name.equals(PdfName.Crypt))
086: throw new NotImplementedException("Crypt");
087:
088: return null;
089: }
090:
091: // </public>
092: // </interface>
093: // </static>
094:
095: // <dynamic>
096: // <constructors>
097: protected Filter() {
098: }
099:
100: // </constructors>
101:
102: // <interface>
103: // <public>
104: public abstract byte[] decode(byte[] data, int offset, int length);
105:
106: public abstract byte[] encode(byte[] data, int offset, int length);
107: // </public>
108: // </interface>
109: // </dynamic>
110: // </class>
111: }
|