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.xml.internal.utils; 23 24/** 25 * The default implementation of XMLStringFactory. 26 * This implementation creates XMLStringDefault objects. 27 */ 28public class XMLStringFactoryDefault extends XMLStringFactory 29{ 30 // A constant representing the empty String 31 private static final XMLStringDefault EMPTY_STR = new XMLStringDefault(""); 32 33 /** 34 * Create a new XMLString from a Java string. 35 * 36 * 37 * @param string Java String reference, which must be non-null. 38 * 39 * @return An XMLString object that wraps the String reference. 40 */ 41 public XMLString newstr(String string) 42 { 43 return new XMLStringDefault(string); 44 } 45 46 /** 47 * Create a XMLString from a FastStringBuffer. 48 * 49 * 50 * @param fsb FastStringBuffer reference, which must be non-null. 51 * @param start The start position in the array. 52 * @param length The number of characters to read from the array. 53 * 54 * @return An XMLString object that wraps the FastStringBuffer reference. 55 */ 56 public XMLString newstr(FastStringBuffer fsb, int start, int length) 57 { 58 return new XMLStringDefault(fsb.getString(start, length)); 59 } 60 61 /** 62 * Create a XMLString from a FastStringBuffer. 63 * 64 * 65 * @param string FastStringBuffer reference, which must be non-null. 66 * @param start The start position in the array. 67 * @param length The number of characters to read from the array. 68 * 69 * @return An XMLString object that wraps the FastStringBuffer reference. 70 */ 71 public XMLString newstr(char[] string, int start, int length) 72 { 73 return new XMLStringDefault(new String(string, start, length)); 74 } 75 76 /** 77 * Get a cheap representation of an empty string. 78 * 79 * @return An non-null reference to an XMLString that represents "". 80 */ 81 public XMLString emptystr() 82 { 83 return EMPTY_STR; 84 } 85} 86