KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xpath > objects > XMLStringFactoryImpl


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: XMLStringFactoryImpl.java,v 1.6 2004/02/17 04:34:38 minchau Exp $
18  */

19 package org.apache.xpath.objects;
20
21 import org.apache.xml.utils.FastStringBuffer;
22 import org.apache.xml.utils.XMLString;
23 import org.apache.xml.utils.XMLStringFactory;
24
25 /**
26  * Class XMLStringFactoryImpl creates XString versions of XMLStrings.
27  * @xsl.usage internal
28  */

29 public class XMLStringFactoryImpl extends XMLStringFactory
30 {
31   /** The XMLStringFactory to pass to DTM construction. */
32   private static XMLStringFactory m_xstringfactory =
33     new XMLStringFactoryImpl();
34
35   /**
36    * Get the XMLStringFactory to pass to DTM construction.
37    *
38    *
39    * @return A never-null static reference to a String factory.
40    */

41   public static XMLStringFactory getFactory()
42   {
43     return m_xstringfactory;
44   }
45
46   /**
47    * Create a new XMLString from a Java string.
48    *
49    *
50    * @param string Java String reference, which must be non-null.
51    *
52    * @return An XMLString object that wraps the String reference.
53    */

54   public XMLString newstr(String JavaDoc string)
55   {
56     return new XString(string);
57   }
58
59   /**
60    * Create a XMLString from a FastStringBuffer.
61    *
62    *
63    * @param string FastStringBuffer reference, which must be non-null.
64    * @param start The start position in the array.
65    * @param length The number of characters to read from the array.
66    *
67    * @return An XMLString object that wraps the FastStringBuffer reference.
68    */

69   public XMLString newstr(FastStringBuffer fsb, int start, int length)
70   {
71     return new XStringForFSB(fsb, start, length);
72   }
73   
74   /**
75    * Create a XMLString from a FastStringBuffer.
76    *
77    *
78    * @param string FastStringBuffer reference, which must be non-null.
79    * @param start The start position in the array.
80    * @param length The number of characters to read from the array.
81    *
82    * @return An XMLString object that wraps the FastStringBuffer reference.
83    */

84   public XMLString newstr(char[] string, int start, int length)
85   {
86     return new XStringForChars(string, start, length);
87   }
88   
89   /**
90    * Get a cheap representation of an empty string.
91    *
92    * @return An non-null reference to an XMLString that represents "".
93    */

94   public XMLString emptystr()
95   {
96     return XString.EMPTYSTRING;
97   }
98
99 }
100
Popular Tags