001/*-------------------------------------------------------------------------+
002|                                                                          |
003| Copyright 2005-2011 the ConQAT Project                                   |
004|                                                                          |
005| Licensed under the Apache License, Version 2.0 (the "License");          |
006| you may not use this file except in compliance with the License.         |
007| You may obtain a copy of the License at                                  |
008|                                                                          |
009|    http://www.apache.org/licenses/LICENSE-2.0                            |
010|                                                                          |
011| Unless required by applicable law or agreed to in writing, software      |
012| distributed under the License is distributed on an "AS IS" BASIS,        |
013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
014| See the License for the specific language governing permissions and      |
015| limitations under the License.                                           |
016+-------------------------------------------------------------------------*/
017package org.conqat.lib.commons.serialization.classes;
018
019import java.io.IOException;
020
021import org.conqat.lib.commons.serialization.SerializedEntityParser;
022
023/**
024 * Field for arbitrary object.
025 */
026public class SerializedObjectField extends SerializedComplexFieldBase {
027
028        /** The type code for this kind of field. */
029        public static final char TYPE_CODE = 'L';
030
031        /**
032         * Constructor for creating a non-functional field that is only used for
033         * read/write.
034         */
035        public SerializedObjectField() throws IOException {
036                super(null, (SerializedEntityParser) null);
037        }
038
039        /** Constructor. */
040        public SerializedObjectField(String fieldName, SerializedEntityParser parser) throws IOException {
041                super(fieldName, parser);
042        }
043
044        /**
045         * Constructor.
046         * 
047         * @param jvmTypeName
048         *            the fully qualified type in JVM internal notation.
049         */
050        public SerializedObjectField(String fieldName, String jvmTypeName) {
051                super(fieldName, jvmTypeName);
052        }
053
054        /**
055         * Converts a plain class name (dot separated) to JVM notation, such as
056         * "Ljava/lang/String;".
057         */
058        public static String createJvmNotationFromPlainClassName(String fullyQualifiedType) {
059                return TYPE_CODE + fullyQualifiedType.replace('.', '/') + ";";
060        }
061
062        /** {@inheritDoc} */
063        @Override
064        protected char getTypeCode() {
065                return TYPE_CODE;
066        }
067}