1 /* 2 * Copyright (C) 2007 The Android Open Source Project 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 package libcore.util; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.annotation.SystemApi; 22 23 import com.android.org.kxml2.io.KXmlParser; 24 import com.android.org.kxml2.io.KXmlSerializer; 25 import org.apache.harmony.xml.ExpatReader; 26 import org.xml.sax.XMLReader; 27 import org.xmlpull.v1.XmlPullParser; 28 import org.xmlpull.v1.XmlSerializer; 29 30 /** 31 * An internal class for creating platform-default XML parsers and related objects. 32 * 33 * @hide 34 */ 35 @SystemApi(client = MODULE_LIBRARIES) 36 public class XmlObjectFactory { 37 XmlObjectFactory()38 private XmlObjectFactory() {} 39 40 /** 41 * Returns a new instance of the platform default {@link XmlSerializer} more efficiently than 42 * using {@code XmlPullParserFactory.newInstance().newSerializer()}. 43 * 44 * @return platform default {@link XmlSerializer} 45 * 46 * @hide 47 */ 48 @SystemApi(client = MODULE_LIBRARIES) newXmlSerializer()49 public static @NonNull XmlSerializer newXmlSerializer() { 50 return new KXmlSerializer(); 51 } 52 53 /** 54 * Returns a new instance of the platform default {@link XmlPullParser} more efficiently than 55 * using {@code XmlPullParserFactory.newInstance().newPullParser()}. 56 * 57 * @return platform default {@link XmlPullParser} 58 * 59 * @hide 60 */ 61 @SystemApi(client = MODULE_LIBRARIES) newXmlPullParser()62 public static @NonNull XmlPullParser newXmlPullParser() { 63 return new KXmlParser(); 64 } 65 66 /** 67 * Returns the plaform default {@link XMLReader}. 68 * 69 * @return plaform default {@link XMLReader} 70 * 71 * @hide 72 */ 73 @SystemApi(client = MODULE_LIBRARIES) newXMLReader()74 public static @NonNull XMLReader newXMLReader() { 75 return new ExpatReader(); 76 } 77 } 78