001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.shared.ldap.extras.extended;
021
022
023import org.apache.directory.shared.util.Strings;
024
025
026/**
027 * Bean for representing a Stored Procedure Parameter
028 * 
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 */
031public class StoredProcedureParameter
032{
033    /** the type of the parameter */
034    private byte[] type;
035    /** the value of the parameter */
036    private byte[] value;
037
038
039    /**
040     * Gets the type as a UTF8 String.
041     *
042     * @return The type as a UTF8 String.
043     */
044    public String getTypeString()
045    {
046        return Strings.utf8ToString( type );
047    }
048    
049    
050    /**
051     * Gets the value as a UTF8 String.
052     *
053     * @return The value as a UTF8 String.
054     */
055    public String getValueString()
056    {
057        return Strings.utf8ToString( value );
058    }
059    
060    
061    /**
062     * Gets the type as a byte[].
063     *
064     * @return The type as a byte[].
065     */
066    public byte[] getType()
067    {
068        if ( type == null )
069        {
070            return null;
071        }
072
073        final byte[] copy = new byte[ type.length ];
074        System.arraycopy( type, 0, copy, 0, type.length );
075        return copy;
076    }
077
078
079    /**
080     * Sets the type.
081     * 
082     * @param type The type as a byte[].
083     */
084    public void setType( byte[] type )
085    {
086        if ( type != null )
087        {
088            this.type = new byte[ type.length ];
089            System.arraycopy( type, 0, this.type, 0, type.length );
090        } 
091        else 
092        {
093            this.type = null;
094        }
095    }
096
097
098    /**
099     * Gets the value as a byte[].
100     *
101     * @return The value as a byte[].
102     */
103    public byte[] getValue()
104    {
105        if ( value == null )
106        {
107            return null;
108        }
109
110        final byte[] copy = new byte[ value.length ];
111        System.arraycopy( value, 0, copy, 0, value.length );
112        return copy;
113    }
114
115
116    /**
117     * Sets the value.
118     * 
119     * @param value The value as a byte[].
120     */
121    public void setValue( byte[] value )
122    {
123        if ( value != null )
124        {
125            this.value = new byte[ value.length ];
126            System.arraycopy( value, 0, this.value, 0, value.length );
127        } 
128        else 
129        {
130            this.value = null;
131        }
132    }
133}