PageRenderTime 56ms CodeModel.GetById 48ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/XML/xml/completion/EntityDecl.java

#
Java | 82 lines | 53 code | 11 blank | 18 comment | 7 complexity | 86e8ce14cc373e945f0152e08bbb130f MD5 | raw file
 1/*
 2 * EntityDecl.java
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2001 Slava Pestov
 7 *
 8 * The XML plugin is licensed under the GNU General Public License, with
 9 * the following exception:
10 *
11 * "Permission is granted to link this code with software released under
12 * the Apache license version 1.1, for example used by the Xerces XML
13 * parser package."
14 */
15
16package xml.completion;
17
18import org.gjt.sp.jedit.MiscUtilities;
19import org.gjt.sp.util.StandardUtilities;
20
21import java.util.Comparator;
22
23public class EntityDecl
24{
25	public static final int INTERNAL = 0;
26	public static final int EXTERNAL = 1;
27
28	public int type;
29
30	public String name;
31	public String value;
32	public String publicId;
33	public String systemId;
34
35	//{{{ EntityDecl constructor
36	public EntityDecl(int type, String name, String value)
37	{
38		this.type = type;
39		this.name = name;
40		this.value = value;
41	} //}}}
42
43	//{{{ EntityDecl constructor
44	public EntityDecl(int type, String name, String publicId, String systemId)
45	{
46		this.type = type;
47		this.name = name;
48		this.publicId = publicId;
49		this.systemId = systemId;
50	} //}}}
51
52	//{{{ toString() method
53	public String toString()
54	{
55		if(type == INTERNAL)
56			return getClass().getName() + "[" + name + "," + value + "]";
57		else if(type == EXTERNAL)
58			return getClass().getName() + "[" + name
59				+ "," + publicId + "," + systemId + "]";
60		else
61			return null;
62	} //}}}
63
64	//{{{ Compare class
65	public static class Compare implements Comparator
66	{
67		public int compare(Object obj1, Object obj2)
68		{
69			EntityDecl entity1 = (EntityDecl)obj1;
70			EntityDecl entity2 = (EntityDecl)obj2;
71
72			if(entity1.type != entity2.type)
73				return entity2.type - entity1.type;
74			else
75			{
76				return StandardUtilities.compareStrings(
77					entity1.name,
78					entity2.name,true);
79			}
80		}
81	} //}}}
82}