1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package org.apache.harmony.security.x509; 19 20import org.apache.harmony.security.utils.Array; 21 22/** 23 * Base class for extension value structures. 24 */ 25public class ExtensionValue { 26 27 /** 28 * Encoded form of the extension. 29 */ 30 protected byte[] encoding; 31 32 /** 33 * Default constructor. 34 */ 35 public ExtensionValue() { } 36 37 /** 38 * Creates the object on the base of its encoded form. 39 */ 40 public ExtensionValue(byte[] encoding) { 41 this.encoding = encoding; 42 } 43 44 /** 45 * Returns encoded form of the object. 46 */ 47 public byte[] getEncoded() { 48 return encoding; 49 } 50 51 /** 52 * Places the string representation of extension value 53 * into the StringBuffer object. 54 */ 55 public void dumpValue(StringBuffer buffer, String prefix) { 56 buffer.append(prefix).append("Unparseable extension value:\n"); //$NON-NLS-1$ 57 if (encoding == null) { 58 encoding = getEncoded(); 59 } 60 if (encoding == null) { 61 buffer.append("NULL\n"); //$NON-NLS-1$ 62 } else { 63 buffer.append(Array.toString(encoding, prefix)); 64 } 65 } 66 67 /** 68 * Places the string representation of extension value 69 * into the StringBuffer object. 70 */ 71 public void dumpValue(StringBuffer buffer) { 72 dumpValue(buffer, ""); //$NON-NLS-1$ 73 }; 74} 75 76