01: /*
02: * $Id: LocationImpl.java,v 1.2 2006/04/01 06:01:34 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.stream.Location;
32:
33: /**
34: *Implementation of Location interface to be used by
35: *event readers.
36: *@author Neeraj.bajaj@sun.com,k.venugopal@sun.com
37: */
38: public class LocationImpl implements Location {
39: String systemId;
40: String publicId;
41: int colNo;
42: int lineNo;
43: int charOffset;
44:
45: LocationImpl(Location loc) {
46: systemId = loc.getSystemId();
47: publicId = loc.getPublicId();
48: lineNo = loc.getLineNumber();
49: colNo = loc.getColumnNumber();
50: charOffset = loc.getCharacterOffset();
51: }
52:
53: public int getCharacterOffset() {
54: return charOffset;
55: }
56:
57: public int getColumnNumber() {
58: return colNo;
59: }
60:
61: public int getLineNumber() {
62: return lineNo;
63: }
64:
65: public String getPublicId() {
66: return publicId;
67: }
68:
69: public String getSystemId() {
70: return systemId;
71: }
72:
73: public String toString() {
74: StringBuffer sbuffer = new StringBuffer();
75: sbuffer.append("Line number = " + getLineNumber());
76: sbuffer.append("\n");
77: sbuffer.append("Column number = " + getColumnNumber());
78: sbuffer.append("\n");
79: sbuffer.append("System Id = " + getSystemId());
80: sbuffer.append("\n");
81: sbuffer.append("Public Id = " + getPublicId());
82: sbuffer.append("\n");
83: sbuffer.append("CharacterOffset = " + getCharacterOffset());
84: sbuffer.append("\n");
85: return sbuffer.toString();
86: }
87:
88: }
|