001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id$ */
019:
020: package org.apache.xmlgraphics.ps.dsc.events;
021:
022: import java.io.IOException;
023:
024: import org.apache.xmlgraphics.ps.PSGenerator;
025:
026: /**
027: * Represents a DSC comment that is not parsed into one of the concrete DSCComment subclasses.
028: * It is used whenever a DSC comment is encountered that is unknown to the parser.
029: * @see org.apache.xmlgraphics.ps.dsc.DSCCommentFactory
030: */
031: public class UnparsedDSCComment extends AbstractEvent implements
032: DSCComment {
033:
034: private String name;
035: private String value;
036:
037: /**
038: * Creates a new instance.
039: * @param name the name of the DSC comment
040: */
041: public UnparsedDSCComment(String name) {
042: this .name = name;
043: }
044:
045: /**
046: * @see org.apache.xmlgraphics.ps.dsc.events.DSCComment#getName()
047: */
048: public String getName() {
049: return this .name;
050: }
051:
052: /**
053: * @see org.apache.xmlgraphics.ps.dsc.events.DSCComment#hasValues()
054: */
055: public boolean hasValues() {
056: return value != null;
057: }
058:
059: /**
060: * @see org.apache.xmlgraphics.ps.dsc.events.DSCComment#isAtend()
061: */
062: public boolean isAtend() {
063: return false;
064: }
065:
066: /**
067: * @see org.apache.xmlgraphics.ps.dsc.events.DSCComment#parseValue(java.lang.String)
068: */
069: public void parseValue(String value) {
070: this .value = value;
071: }
072:
073: /**
074: * @see org.apache.xmlgraphics.ps.dsc.events.DSCEvent#generate(org.apache.xmlgraphics.ps.PSGenerator)
075: */
076: public void generate(PSGenerator gen) throws IOException {
077: gen.writeln("%%" + name + (hasValues() ? ": " + value : ""));
078: }
079:
080: /**
081: * @see org.apache.xmlgraphics.ps.dsc.events.AbstractEvent#isDSCComment()
082: */
083: public boolean isDSCComment() {
084: return true;
085: }
086:
087: /**
088: * @see org.apache.xmlgraphics.ps.dsc.events.DSCEvent#getEventType()
089: */
090: public int getEventType() {
091: return DSC_COMMENT;
092: }
093:
094: /**
095: * @see org.apache.xmlgraphics.ps.dsc.events.AbstractEvent#asDSCComment()
096: */
097: public DSCComment asDSCComment() {
098: return this;
099: }
100:
101: }
|