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 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 37 public class XmlObjectFactory { 38 XmlObjectFactory()39 private XmlObjectFactory() {} 40 41 /** 42 * Returns a new instance of the platform default {@link XmlSerializer} more efficiently than 43 * using {@code XmlPullParserFactory.newInstance().newSerializer()}. 44 * 45 * @return platform default {@link XmlSerializer} 46 * 47 * @hide 48 */ 49 @SystemApi(client = MODULE_LIBRARIES) 50 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) newXmlSerializer()51 public static @NonNull XmlSerializer newXmlSerializer() { 52 return new KXmlSerializer(); 53 } 54 55 /** 56 * Returns a new instance of the platform default {@link XmlPullParser} more efficiently than 57 * using {@code XmlPullParserFactory.newInstance().newPullParser()}. 58 * 59 * @return platform default {@link XmlPullParser} 60 * 61 * @hide 62 */ 63 @SystemApi(client = MODULE_LIBRARIES) 64 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) newXmlPullParser()65 public static @NonNull XmlPullParser newXmlPullParser() { 66 return new KXmlParser(); 67 } 68 69 /** 70 * Returns the plaform default {@link XMLReader}. 71 * 72 * @return plaform default {@link XMLReader} 73 * 74 * @hide 75 */ 76 @SystemApi(client = MODULE_LIBRARIES) 77 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) newXMLReader()78 public static @NonNull XMLReader newXMLReader() { 79 return new ExpatReader(); 80 } 81 } 82