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