01: /*
02: * $Id: NamedEvent.java,v 1.2 2006/04/01 06:01:35 jeffsuttor Exp $
03: */
04:
05: /*
06: * The contents of this file are subject to the terms
07: * of the Common Development and Distribution License
08: * (the License). You may not use this file except in
09: * compliance with the License.
10: *
11: * You can obtain a copy of the license at
12: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
13: * See the License for the specific language governing
14: * permissions and limitations under the License.
15: *
16: * When distributing Covered Code, include this CDDL
17: * Header Notice in each file and include the License file
18: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
19: * If applicable, add the following below the CDDL Header,
20: * with the fields enclosed by brackets [] replaced by
21: * you own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * [Name of File] [ver.__] [Date]
25: *
26: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
27: */
28:
29: package com.sun.xml.stream.events;
30:
31: import javax.xml.namespace.QName;
32:
33: /**
34: *
35: *@author Neeraj Bajaj, Sun Microsystems
36: *
37: */
38: public class NamedEvent extends DummyEvent {
39:
40: private QName name;
41:
42: public NamedEvent() {
43: }
44:
45: public NamedEvent(QName qname) {
46: this .name = qname;
47: }
48:
49: public NamedEvent(String prefix, String uri, String localpart) {
50: this .name = new QName(uri, localpart, prefix);
51: }
52:
53: public String getPrefix() {
54: return this .name.getPrefix();
55: }
56:
57: public QName getName() {
58: return name;
59: }
60:
61: public void setName(QName qname) {
62: this .name = qname;
63: }
64:
65: public String nameAsString() {
66: if ("".equals(name.getNamespaceURI()))
67: return name.getLocalPart();
68: if (name.getPrefix() != null)
69: return "['" + name.getNamespaceURI() + "']:" + getPrefix()
70: + ":" + name.getLocalPart();
71: else
72: return "['" + name.getNamespaceURI() + "']:"
73: + name.getLocalPart();
74: }
75:
76: public String getNamespace() {
77: return name.getNamespaceURI();
78: }
79:
80: }
|