001 /*
002 * Copyright 2008-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2008-2016 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021 package com.unboundid.util;
022
023
024
025 import java.io.Serializable;
026
027 import com.unboundid.asn1.ASN1OctetString;
028
029
030
031 /**
032 * This interface defines a set of methods for treating a value as either a
033 * string or byte array.
034 */
035 @NotExtensible()
036 @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
037 public interface ByteString
038 extends Serializable
039 {
040 /**
041 * Retrieves a byte array containing the binary value for this byte string.
042 *
043 * @return A byte array containing the binary value for this byte string.
044 */
045 byte[] getValue();
046
047
048
049 /**
050 * Retrieves the value for this byte string as a {@code String}.
051 *
052 * @return The value for this byte string as a {@code String}.
053 */
054 String stringValue();
055
056
057
058 /**
059 * Appends the value of this byte string to the provided buffer. It must not
060 * use the {@link ByteStringBuffer#append(ByteString)} method, since that
061 * method relies on this method.
062 *
063 * @param buffer The buffer to which the value should be appended.
064 */
065 void appendValueTo(final ByteStringBuffer buffer);
066
067
068
069 /**
070 * Converts this byte string to an ASN.1 octet string.
071 *
072 * @return An ASN.1 octet string with the value of this byte string.
073 */
074 ASN1OctetString toASN1OctetString();
075 }