1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 1999-2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 /* 21 * $Id: XMLStringFactoryImpl.java,v 1.2.4.1 2005/09/10 17:44:29 jeffsuttor Exp $ 22 */ 23 package com.sun.org.apache.xpath.internal.objects; 24 25 import com.sun.org.apache.xml.internal.utils.FastStringBuffer; 26 import com.sun.org.apache.xml.internal.utils.XMLString; 27 import com.sun.org.apache.xml.internal.utils.XMLStringFactory; 28 29 /** 30 * Class XMLStringFactoryImpl creates XString versions of XMLStrings. 31 * @xsl.usage internal 32 */ 33 public class XMLStringFactoryImpl extends XMLStringFactory 34 { 35 /** The XMLStringFactory to pass to DTM construction. */ 36 private static XMLStringFactory m_xstringfactory = 37 new XMLStringFactoryImpl(); 38 39 /** 40 * Get the XMLStringFactory to pass to DTM construction. 41 * 42 * 43 * @return A never-null static reference to a String factory. 44 */ getFactory()45 public static XMLStringFactory getFactory() 46 { 47 return m_xstringfactory; 48 } 49 50 /** 51 * Create a new XMLString from a Java string. 52 * 53 * 54 * @param string Java String reference, which must be non-null. 55 * 56 * @return An XMLString object that wraps the String reference. 57 */ newstr(String string)58 public XMLString newstr(String string) 59 { 60 return new XString(string); 61 } 62 63 /** 64 * Create a XMLString from a FastStringBuffer. 65 * 66 * 67 * @param fsb FastStringBuffer reference, which must be non-null. 68 * @param start The start position in the array. 69 * @param length The number of characters to read from the array. 70 * 71 * @return An XMLString object that wraps the FastStringBuffer reference. 72 */ newstr(FastStringBuffer fsb, int start, int length)73 public XMLString newstr(FastStringBuffer fsb, int start, int length) 74 { 75 return new XStringForFSB(fsb, start, length); 76 } 77 78 /** 79 * Create a XMLString from a FastStringBuffer. 80 * 81 * 82 * @param string FastStringBuffer reference, which must be non-null. 83 * @param start The start position in the array. 84 * @param length The number of characters to read from the array. 85 * 86 * @return An XMLString object that wraps the FastStringBuffer reference. 87 */ newstr(char[] string, int start, int length)88 public XMLString newstr(char[] string, int start, int length) 89 { 90 return new XStringForChars(string, start, length); 91 } 92 93 /** 94 * Get a cheap representation of an empty string. 95 * 96 * @return An non-null reference to an XMLString that represents "". 97 */ emptystr()98 public XMLString emptystr() 99 { 100 return XString.EMPTYSTRING; 101 } 102 103 } 104