1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.helger.schematron.pure.model;
18
19 import java.io.Serializable;
20
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23 import javax.annotation.concurrent.NotThreadSafe;
24 import javax.xml.XMLConstants;
25
26 import com.helger.commons.annotation.Nonempty;
27 import com.helger.commons.id.IHasID;
28 import com.helger.commons.lang.EnumHelper;
29 import com.helger.commons.lang.ICloneable;
30 import com.helger.commons.microdom.IMicroElement;
31 import com.helger.commons.string.ToStringGenerator;
32 import com.helger.schematron.CSchematronXML;
33
34
35
36
37
38
39 @NotThreadSafe
40 public class PSRichGroup implements ICloneable <PSRichGroup>, Serializable
41 {
42 public static enum ESpace implements IHasID <String>
43 {
44 PRESERVE ("preserve"),
45 DEFAULT ("default");
46
47 private final String m_sID;
48
49 private ESpace (@Nonnull @Nonempty final String sID)
50 {
51 m_sID = sID;
52 }
53
54 @Nonnull
55 @Nonempty
56 public String getID ()
57 {
58 return m_sID;
59 }
60
61 @Nullable
62 public static ESpace getFromIDOrNull (@Nullable final String sID)
63 {
64 return EnumHelper.getFromIDOrNull (ESpace.class, sID);
65 }
66 }
67
68 private String m_sIcon;
69 private String m_sSee;
70 private String m_sFPI;
71 private String m_sXmlLang;
72 private ESpace m_eXmlSpace;
73
74 public PSRichGroup ()
75 {}
76
77 public void setIcon (@Nullable final String sIcon)
78 {
79 m_sIcon = sIcon;
80 }
81
82
83
84
85
86
87
88
89 @Nullable
90 public String getIcon ()
91 {
92 return m_sIcon;
93 }
94
95 public void setSee (@Nullable final String sSee)
96 {
97 m_sSee = sSee;
98 }
99
100
101
102
103
104
105
106
107 @Nullable
108 public String getSee ()
109 {
110 return m_sSee;
111 }
112
113 public void setFPI (@Nullable final String sFPI)
114 {
115 m_sFPI = sFPI;
116 }
117
118
119
120
121
122
123
124 @Nullable
125 public String getFPI ()
126 {
127 return m_sFPI;
128 }
129
130 public void setXmlLang (@Nullable final String sXmlLang)
131 {
132 m_sXmlLang = sXmlLang;
133 }
134
135 @Nullable
136 public String getXmlLang ()
137 {
138 return m_sXmlLang;
139 }
140
141 public void setXmlSpace (@Nullable final ESpace eXmlSpace)
142 {
143 m_eXmlSpace = eXmlSpace;
144 }
145
146 @Nullable
147 public ESpace getXmlSpace ()
148 {
149 return m_eXmlSpace;
150 }
151
152 public static boolean isRichAttribute (@Nullable final String sAttrName)
153 {
154 return CSchematronXML.ATTR_ICON.equals (sAttrName) ||
155 CSchematronXML.ATTR_SEE.equals (sAttrName) ||
156 CSchematronXML.ATTR_FPI.equals (sAttrName) ||
157 CSchematronXML.ATTR_XML_LANG.equals (sAttrName) ||
158 CSchematronXML.ATTR_XML_SPACE.equals (sAttrName);
159 }
160
161 public void fillMicroElement (@Nonnull final IMicroElement aElement)
162 {
163 aElement.setAttribute (CSchematronXML.ATTR_ICON, m_sIcon);
164 aElement.setAttribute (CSchematronXML.ATTR_SEE, m_sSee);
165 aElement.setAttribute (CSchematronXML.ATTR_FPI, m_sFPI);
166 aElement.setAttribute (XMLConstants.XML_NS_URI, CSchematronXML.ATTR_XML_LANG, m_sXmlLang);
167 if (m_eXmlSpace != null)
168 aElement.setAttribute (XMLConstants.XML_NS_URI, CSchematronXML.ATTR_XML_SPACE, m_eXmlSpace.getID ());
169 }
170
171 @Nonnull
172 public PSRichGroup getClone ()
173 {
174 final PSRichGroup ret = new PSRichGroup ();
175 ret.setIcon (m_sIcon);
176 ret.setSee (m_sSee);
177 ret.setFPI (m_sFPI);
178 ret.setXmlLang (m_sXmlLang);
179 ret.setXmlSpace (m_eXmlSpace);
180 return ret;
181 }
182
183 @Override
184 public String toString ()
185 {
186 return new ToStringGenerator (this).appendIfNotNull ("icon", m_sIcon)
187 .appendIfNotNull ("see", m_sSee)
188 .appendIfNotNull ("fpi", m_sFPI)
189 .appendIfNotNull ("xml:lang", m_sXmlLang)
190 .appendIfNotNull ("xml:space", m_eXmlSpace)
191 .toString ();
192 }
193 }