KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > documents > contents > ContentStream


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.documents.contents;
28
29 import it.stefanochizzolini.clown.bytes.IBuffer;
30 import it.stefanochizzolini.clown.documents.contents.composition.ContentBuilder;
31 import it.stefanochizzolini.clown.documents.contents.tokens.Parser;
32 import it.stefanochizzolini.clown.documents.Document;
33 import it.stefanochizzolini.clown.objects.PdfDirectObject;
34 import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
35 import it.stefanochizzolini.clown.objects.PdfStream;
36 import it.stefanochizzolini.clown.util.NotImplementedException;
37
38 /**
39   Content stream [PDF:1.6:3.7.1].
40 */

41 public class ContentStream
42   extends PdfObjectWrapper<PdfStream>
43 {
44   // <class>
45
// <dynamic>
46
// <fields>
47
private Parser parser;
48   private IContentStreamContext streamContext;
49   // </fields>
50

51   // <constructors>
52
public ContentStream(
53     Document context
54     )
55   {
56     super(
57       context.getFile(),
58       new PdfStream()
59       );
60   }
61
62   /**
63     <h3>Remarks</h3>
64     <p>For internal use only.</p>
65   */

66   public ContentStream(
67     PdfDirectObject baseObject,
68     IContentStreamContext streamContext
69     )
70   {
71     super(
72       baseObject,
73       null // NO container (content stream is a PDF stream, so it MUST be an indirect object [PDF:1.6:3.2.7]).
74
);
75
76     this.streamContext = streamContext;
77   }
78   // </constructors>
79

80   // <interface>
81
// <public>
82
/**
83     Appends a fragment to the content stream.
84   */

85   public void append(
86     IBuffer data
87     )
88   {getBaseDataObject().getBody().append(data);}
89
90   public Object JavaDoc clone(
91     Document context
92     )
93   {throw new NotImplementedException();}
94
95   /**
96     Gets the parser associated to the content stream.
97   */

98   public Parser getParser(
99     )
100   {
101     if(parser == null)
102       parser = new Parser(
103         getBaseDataObject().getBody()
104         );
105
106     return parser;
107   }
108
109   /**
110     Gets the context of the content stream.
111   */

112   public IContentStreamContext getStreamContext(
113     )
114   {return streamContext;}
115
116   /**
117     Inserts a fragment to the content stream.
118   */

119   public void insert(
120     int index,
121     IBuffer data
122     )
123   {getBaseDataObject().getBody().insert(index,data);}
124   // </public>
125

126   // <internal>
127
/**
128     Sets the context of the content stream.
129   */

130   void setStreamContext(
131     IContentStreamContext value
132     )
133   {streamContext = value;}
134   // </internal>
135
// </interface>
136
// </dynamic>
137
// </class>
138
}
Popular Tags