01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
18: package org.apache.harmony.security.x509;
19:
20: import org.apache.harmony.security.utils.Array;
21:
22: /**
23: * Base class for extension value structures.
24: */
25: public 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: /**
39: * Creates the object on the base of its encoded form.
40: */
41: public ExtensionValue(byte[] encoding) {
42: this .encoding = encoding;
43: }
44:
45: /**
46: * Returns encoded form of the object.
47: */
48: public byte[] getEncoded() {
49: return encoding;
50: }
51:
52: /**
53: * Places the string representation of extension value
54: * into the StringBuffer object.
55: */
56: public void dumpValue(StringBuffer buffer, String prefix) {
57: buffer.append(prefix).append("Unparseable extension value:\n"); //$NON-NLS-1$
58: if (encoding == null) {
59: encoding = getEncoded();
60: }
61: if (encoding == null) {
62: buffer.append("NULL\n"); //$NON-NLS-1$
63: } else {
64: buffer.append(Array.toString(encoding, prefix));
65: }
66: }
67:
68: /**
69: * Places the string representation of extension value
70: * into the StringBuffer object.
71: */
72: public void dumpValue(StringBuffer buffer) {
73: dumpValue(buffer, ""); //$NON-NLS-1$
74: };
75: }
|