| StAXReaderUtil.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.xml;
16
17 import com.liferay.portal.kernel.util.StringPool;
18
19 import javax.xml.stream.XMLEventReader;
20 import javax.xml.stream.XMLInputFactory;
21 import javax.xml.stream.XMLStreamException;
22 import javax.xml.stream.events.XMLEvent;
23
24 /**
25 * <a href="StAXReaderUtil.java.html"><b><i>View Source</i></b></a>
26 *
27 * @author Shuyang Zhou
28 * @author Brian Wing Shun Chan
29 */
30 public class StAXReaderUtil {
31
32 public static XMLInputFactory getXMLInputFactory() {
33 return _xmlInputFactory;
34 }
35
36 public static String read(XMLEventReader xmlEventReader)
37 throws XMLStreamException {
38
39 XMLEvent xmlEvent = xmlEventReader.peek();
40
41 if (xmlEvent.isCharacters()) {
42 xmlEvent = xmlEventReader.nextEvent();
43
44 return xmlEvent.asCharacters().getData();
45 }
46 else {
47 return StringPool.BLANK;
48 }
49 }
50
51 private static XMLInputFactory _xmlInputFactory =
52 XMLInputFactory.newInstance();
53
54 }