01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id$ */
19:
20: package org.apache.xmlgraphics.ps.dsc.events;
21:
22: import java.io.IOException;
23:
24: import org.apache.xmlgraphics.ps.PSGenerator;
25: import org.apache.xmlgraphics.ps.dsc.DSCParserConstants;
26:
27: /**
28: * Interface representing a DSC event. A DSC event can be a DSC comment, a PostScript comment
29: * or a line of PostScript code.
30: */
31: public interface DSCEvent extends DSCParserConstants {
32:
33: /**
34: * Returns the event type.
35: * @return the event type (see {@link DSCParserConstants})
36: */
37: int getEventType();
38:
39: /**
40: * Casts this instance to a DSCComment if possible.
41: * @return this event as a DSCComment
42: * @throws ClassCastException if the event is no DSCComment
43: */
44: DSCComment asDSCComment();
45:
46: /**
47: * Casts this instance to a PostScriptLine if possible.
48: * @return this event as a PostScriptLine
49: * @throws ClassCastException if the event is no PostScriptLine
50: */
51: PostScriptLine asLine();
52:
53: /**
54: * Indicates whether the instance is a DSC comment.
55: * @return true if the instance is a DSC comment
56: */
57: boolean isDSCComment();
58:
59: /**
60: * Indicates whether the instance is a PostScript comment.
61: * @return true if the instance is a PostScript comment
62: */
63: boolean isComment();
64:
65: /**
66: * Indicates whether the instance is a header comment.
67: * @return true if the instance is a header comment
68: */
69: boolean isHeaderComment();
70:
71: /**
72: * Indicates whether the instance is a PostScript line.
73: * @return true if the instance is a PostScript line
74: */
75: boolean isLine();
76:
77: /**
78: * Writes the event to the given PSGenerator.
79: * @param gen the PSGenerator to write to
80: * @throws IOException In case of an I/O error
81: */
82: void generate(PSGenerator gen) throws IOException;
83:
84: }
|