001 /* 002 * Copyright 2008-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2008-2015 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 public interface ByteString 036 extends Serializable 037 { 038 /** 039 * Retrieves a byte array containing the binary value for this byte string. 040 * 041 * @return A byte array containing the binary value for this byte string. 042 */ 043 byte[] getValue(); 044 045 046 047 /** 048 * Retrieves the value for this byte string as a {@code String}. 049 * 050 * @return The value for this byte string as a {@code String}. 051 */ 052 String stringValue(); 053 054 055 056 /** 057 * Appends the value of this byte string to the provided buffer. It must not 058 * use the {@code ByteStringBuffer#append(ByteString)} method, since that 059 * method relies on this method. 060 * 061 * @param buffer The buffer to which the value should be appended. 062 */ 063 void appendValueTo(final ByteStringBuffer buffer); 064 065 066 067 /** 068 * Converts this byte string to an ASN.1 octet string. 069 * 070 * @return An ASN.1 octet string with the value of this byte string. 071 */ 072 ASN1OctetString toASN1OctetString(); 073 }