View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.extras.extended.storedProcedure;
21  
22  
23  import org.apache.directory.api.util.Strings;
24  
25  
26  /**
27   * Bean for representing a Stored Procedure Parameter
28   * 
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public class StoredProcedureParameter
32  {
33      /** the type of the parameter */
34      private byte[] type;
35  
36      /** the value of the parameter */
37      private byte[] value;
38  
39  
40      /**
41       * Gets the type as a UTF8 String.
42       *
43       * @return The type as a UTF8 String.
44       */
45      public String getTypeString()
46      {
47          return Strings.utf8ToString( type );
48      }
49  
50  
51      /**
52       * Gets the value as a UTF8 String.
53       *
54       * @return The value as a UTF8 String.
55       */
56      public String getValueString()
57      {
58          return Strings.utf8ToString( value );
59      }
60  
61  
62      /**
63       * Gets the type as a byte[].
64       *
65       * @return The type as a byte[].
66       */
67      public byte[] getType()
68      {
69          if ( type == null )
70          {
71              return null;
72          }
73  
74          final byte[] copy = new byte[type.length];
75          System.arraycopy( type, 0, copy, 0, type.length );
76          return copy;
77      }
78  
79  
80      /**
81       * Sets the type.
82       * 
83       * @param type The type as a byte[].
84       */
85      public void setType( byte[] type )
86      {
87          if ( type != null )
88          {
89              this.type = new byte[type.length];
90              System.arraycopy( type, 0, this.type, 0, type.length );
91          }
92          else
93          {
94              this.type = null;
95          }
96      }
97  
98  
99      /**
100      * Gets the value as a byte[].
101      *
102      * @return The value as a byte[].
103      */
104     public byte[] getValue()
105     {
106         if ( value == null )
107         {
108             return null;
109         }
110 
111         final byte[] copy = new byte[value.length];
112         System.arraycopy( value, 0, copy, 0, value.length );
113         return copy;
114     }
115 
116 
117     /**
118      * Sets the value.
119      * 
120      * @param value The value as a byte[].
121      */
122     public void setValue( byte[] value )
123     {
124         if ( value != null )
125         {
126             this.value = new byte[value.length];
127             System.arraycopy( value, 0, this.value, 0, value.length );
128         }
129         else
130         {
131             this.value = null;
132         }
133     }
134 }