001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.types;
028
029
030
031 import org.opends.server.protocols.asn1.ASN1OctetString;
032
033
034
035 /**
036 * This interface defines data type that is backed by a byte array but
037 * may also have a string representation. The preferred way to create
038 * a <CODE>ByteString</CODE> object is to use one of the
039 * <CODE>ByteStringFactory.create</CODE> methods.
040 */
041 @org.opends.server.types.PublicAPI(
042 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
043 mayInstantiate=false,
044 mayExtend=false,
045 mayInvoke=true)
046 public interface ByteString
047 {
048 /**
049 * Retrieves the value of this byte string as a byte array.
050 *
051 * @return The value of this byte string as a byte array.
052 */
053 public byte[] value();
054
055
056
057 /**
058 * Retrieves the value of this byte string as a string.
059 *
060 * @return The value of this byte string as a string.
061 */
062 public String stringValue();
063
064
065
066 /**
067 * Sets the value for this byte string.
068 *
069 * @param value The value for this byte string.
070 */
071 public void setValue(byte[] value);
072
073
074
075 /**
076 * Sets the value for this byte string.
077 *
078 * @param value The value for this byte string.
079 */
080 public void setValue(String value);
081
082
083
084 /**
085 * Retrieves this byte string as an ASN.1 octet string.
086 *
087 * @return An ASN.1 octet string with the value of this byte
088 * string.
089 */
090 public ASN1OctetString toASN1OctetString();
091
092
093
094 /**
095 * Retrieves a string representation of this byte string.
096 *
097 * @return A string representation of this byte string.
098 */
099 public String toString();
100
101
102
103 /**
104 * Appends a string representation of this byte string to the
105 * provided buffer.
106 *
107 * @param buffer The buffer to which the information should be
108 * appended.
109 */
110 public void toString(StringBuilder buffer);
111
112
113
114 /**
115 * Creates a duplicate of this byte string whose contents can be
116 * altered without impacting this byte string.
117 *
118 * @return A duplicate of this byte string.
119 */
120 public ByteString duplicate();
121 }
122