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    /** Encoded form of the extension. */
28    protected byte[] encoding;
29
30    /** Default constructor. */
31    public ExtensionValue() {}
32
33    /** Creates the object on the base of its encoded form. */
34    public ExtensionValue(byte[] encoding) {
35        this.encoding = encoding;
36    }
37
38    /** Returns encoded form of the object. */
39    public byte[] getEncoded() {
40        return encoding;
41    }
42
43    public void dumpValue(StringBuilder sb, String prefix) {
44        sb.append(prefix).append("Unparseable extension value:\n");
45        if (encoding == null) {
46            encoding = getEncoded();
47        }
48        if (encoding == null) {
49            sb.append("NULL\n");
50        } else {
51            sb.append(Array.toString(encoding, prefix));
52        }
53    }
54
55    public void dumpValue(StringBuilder sb) {
56        dumpValue(sb, "");
57    }
58}
59