01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.7 2005/01/23 01:08:21 mcnamara 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: /** The XMLStringFactory to pass to DTM construction. */
31: private static XMLStringFactory m_xstringfactory = new XMLStringFactoryImpl();
32:
33: /**
34: * Get the XMLStringFactory to pass to DTM construction.
35: *
36: *
37: * @return A never-null static reference to a String factory.
38: */
39: public static XMLStringFactory getFactory() {
40: return m_xstringfactory;
41: }
42:
43: /**
44: * Create a new XMLString from a Java string.
45: *
46: *
47: * @param string Java String reference, which must be non-null.
48: *
49: * @return An XMLString object that wraps the String reference.
50: */
51: public XMLString newstr(String string) {
52: return new XString(string);
53: }
54:
55: /**
56: * Create a XMLString from a FastStringBuffer.
57: *
58: *
59: * @param fsb FastStringBuffer reference, which must be non-null.
60: * @param start The start position in the array.
61: * @param length The number of characters to read from the array.
62: *
63: * @return An XMLString object that wraps the FastStringBuffer reference.
64: */
65: public XMLString newstr(FastStringBuffer fsb, int start, int length) {
66: return new XStringForFSB(fsb, start, length);
67: }
68:
69: /**
70: * Create a XMLString from a FastStringBuffer.
71: *
72: *
73: * @param string FastStringBuffer reference, which must be non-null.
74: * @param start The start position in the array.
75: * @param length The number of characters to read from the array.
76: *
77: * @return An XMLString object that wraps the FastStringBuffer reference.
78: */
79: public XMLString newstr(char[] string, int start, int length) {
80: return new XStringForChars(string, start, length);
81: }
82:
83: /**
84: * Get a cheap representation of an empty string.
85: *
86: * @return An non-null reference to an XMLString that represents "".
87: */
88: public XMLString emptystr() {
89: return XString.EMPTYSTRING;
90: }
91:
92: }
|