www.pudn.com > cryptix-asn1-0.1.11.zip > GraphicString.java
/* $Id: GraphicString.java,v 1.2 2001/05/24 16:52:49 raif Exp $ * * Copyright (C) 1997-2001 The Cryptix Foundation Limited. All rights reserved. * * Use, modification, copying and distribution of this software is subject to * the terms and conditions of the Cryptix General Licence. You should have * received a copy of the Cryptix General Licence along with this library; if * not, you can download a copy from http://www.cryptix.org/ */ package cryptix.asn1.lang; import cryptix.asn1.io.ASNReader; import cryptix.asn1.io.ASNWriter; import cryptix.asn1.io.BlankElementException; import cryptix.asn1.io.ElementNotFoundException; import org.apache.log4j.Category; import java.io.EOFException; import java.io.IOException; /** * The basic implementation of an ASN.1 GraphicString type.* * @version $Revision: 1.2 $ * @author Raif S. Naffah */ public class GraphicString extends ASNString implements IType { // Constants and vars // ....................................................................... static Category cat = Category.getInstance(GraphicString.class.getName()); // Constructor(s) // ....................................................................... public GraphicString() { super("", new Tag(Tag.GRAPHIC_STRING)); } public GraphicString(String name) { super(name, new Tag(Tag.GRAPHIC_STRING)); } public GraphicString(String name, Tag tag) { super(name, tag); } public GraphicString(String name, Object value) { this(name, new Tag(Tag.GRAPHIC_STRING), value); } /** * Constructs a new instance of a GraphicString type, given a designated * Tag and a designated initial value. * * @param name the name of this instance. * @param tag the designated Tag value. * @param value the designated initial value. Allowed types are: * java.lang.String, and any subclass of cryptix.asn1.lang.ASNString. * @exception ClassCastException if the designated value is not a String. */ public GraphicString(String name, Tag tag, Object value) { super(name, tag); value(value); if (this.value != null) defaultValue(this.value); } // Class methods // ....................................................................... /** * Returns a new instance of this type with a trivial name and the * designated value. * * @param value a designated initial value for the new instance. * @return a new instance with the designated value. * @exception ClassCastException if the designated value is not appropriate * (see constructor with 3 arguments for suitable types of value). */ public static GraphicString getInstance(String value) { return new GraphicString("", value); } /** * Returns a new instance of this type with a trivial name and the * designated value. * * @param value a designated initial value for the new instance. * @return a new instance with the designated value. * @exception ClassCastException if the designated value is not appropriate * (see constructor with 3 arguments for suitable types of value). */ public static GraphicString getInstance(ASNString value) { return new GraphicString("", value); } // Redefinition of methods in superclass Type // ....................................................................... /** * Decodes a GraphicString from an input stream. * * @param is the ASN.1 stream to read from. * @exception IOException if an exception occurs during the operation. */ public void decode(ASNReader is) throws IOException { this.decodeInternal(is, Tag.GRAPHIC_STRING); } /** * Encodes a GraphicString to an output stream. * * @param os the ASN.1 stream to write to. * @exception IOException if an exception occurs during the operation. */ public void encode(ASNWriter os) throws IOException { this.encodeInternal(os, Tag.GRAPHIC_STRING); } }