KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > xdoclet > typesystem > impl > env > SourcePositionImpl


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.env;
19
20 import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition;
21 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.DelegatingImpl;
22 import org.apache.beehive.netui.xdoclet.XDocletUtils;
23 import xjavadoc.SourceClass;
24 import xjavadoc.XClass;
25 import xjavadoc.XProgramElement;
26 import xjavadoc.XTag;
27
28 import java.io.File JavaDoc;
29
30 public class SourcePositionImpl
31         extends DelegatingImpl
32         implements SourcePosition
33 {
34     private SourceClass _outerClass;
35     private int _line = -1;
36     private String JavaDoc _memberName;
37     
38     protected SourcePositionImpl( XProgramElement element, SourceClass outerClass )
39     {
40         super( element );
41         _outerClass = outerClass;
42     }
43     
44     protected SourcePositionImpl( XTag tag, SourceClass outerClass )
45     {
46         super( tag );
47         _outerClass = outerClass;
48         _line = tag.getLineNumber();
49     }
50     
51     protected SourcePositionImpl( XTag tag, String JavaDoc memberName, SourceClass outerClass )
52     {
53         super( tag );
54         _outerClass = outerClass;
55         _line = tag.getLineNumber();
56         _memberName = memberName;
57     }
58     
59     public static SourcePosition get( XProgramElement element )
60     {
61         if ( element == null ) return null;
62         XClass outerClass = XDocletUtils.getOutermostClass( element );
63         return outerClass instanceof SourceClass ? new SourcePositionImpl( element, ( SourceClass ) outerClass ) : null;
64     }
65     
66     public static SourcePosition get( XTag tag, XProgramElement element )
67     {
68         if ( element == null ) return null;
69         XClass outerClass = XDocletUtils.getOutermostClass( element );
70         return outerClass instanceof SourceClass ? new SourcePositionImpl( tag, ( SourceClass ) outerClass ) : null;
71     }
72     
73     public static SourcePositionImpl get( XTag tag, String JavaDoc memberName, XProgramElement element )
74     {
75         if ( element == null ) return null;
76         XClass outerClass = XDocletUtils.getOutermostClass( element );
77         return outerClass instanceof SourceClass ? new SourcePositionImpl( tag, memberName, ( SourceClass ) outerClass ) : null;
78     }
79
80     public File JavaDoc file()
81     {
82         return new File JavaDoc( _outerClass.getFile().getPath() );
83     }
84
85     public int line()
86     {
87         return _line;
88     }
89
90     public int column()
91     {
92         assert false : "NYI";
93         return 0;
94     }
95     
96     public XClass getOuterClass()
97     {
98         return _outerClass;
99     }
100     
101     public String JavaDoc getMemberName()
102     {
103         return _memberName;
104     }
105 }
106
Popular Tags