KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jcr > base > BaseValueFactory


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.jcr.base;
31
32 import com.caucho.util.L10N;
33
34 import javax.jcr.Node;
35 import javax.jcr.PropertyType;
36 import javax.jcr.RepositoryException;
37 import javax.jcr.Value;
38 import javax.jcr.ValueFactory;
39 import javax.jcr.ValueFormatException;
40 import java.io.InputStream JavaDoc;
41 import java.util.Calendar JavaDoc;
42
43 /**
44  * Creates a value.
45  */

46 public class BaseValueFactory implements ValueFactory {
47   private static final L10N L = new L10N(BaseValueFactory.class);
48
49   public static final ValueFactory FACTORY = new BaseValueFactory();
50
51   /**
52    * Returns the expected property type.
53    */

54   protected int getPropertyType()
55   {
56     return PropertyType.STRING;
57   }
58   
59   /**
60    * Creates a value based on a string.
61    */

62   public Value createValue(String JavaDoc value)
63   {
64     throw new UnsupportedOperationException JavaDoc();
65   }
66   
67   /**
68    * Creates a value based on a string, coerced to the expected PropertyType.
69    *
70    * @param value the new value
71    * @param type the expected PropertyType.
72    */

73   public Value createValue(String JavaDoc value, int type)
74     throws ValueFormatException
75   {
76     throw new UnsupportedOperationException JavaDoc(getClass().getName());
77   }
78
79   /**
80    * Creates a value based on a long.
81    */

82   public Value createValue(long value)
83   {
84     throw new UnsupportedOperationException JavaDoc();
85   }
86   
87   /**
88    * Creates a value based on a double.
89    */

90   public Value createValue(double value)
91   {
92     throw new UnsupportedOperationException JavaDoc();
93   }
94   
95   /**
96    * Creates a value based on a boolean.
97    */

98   public Value createValue(boolean value)
99   {
100     throw new UnsupportedOperationException JavaDoc();
101   }
102   
103   /**
104    * Creates a value based on a date.
105    */

106   public Value createValue(Calendar JavaDoc value)
107   {
108     throw new UnsupportedOperationException JavaDoc();
109   }
110   
111   /**
112    * Creates a value based on a binary stream.
113    */

114   public Value createValue(InputStream JavaDoc value)
115   {
116     throw new UnsupportedOperationException JavaDoc();
117   }
118   
119   /**
120    * Creates a value based on a node reference
121    */

122   public Value createValue(Node value)
123     throws RepositoryException
124   {
125     return createValue(String.valueOf(value), getPropertyType());
126   }
127 }
128
Popular Tags