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 javax.annotation.Nonnull;
20 import javax.annotation.Nullable;
21 import javax.annotation.concurrent.NotThreadSafe;
22
23 import com.helger.commons.string.StringHelper;
24 import com.helger.commons.string.ToStringGenerator;
25 import com.helger.schematron.CSchematron;
26 import com.helger.schematron.CSchematronXML;
27 import com.helger.schematron.pure.errorhandler.IPSErrorHandler;
28 import com.helger.xml.microdom.IMicroElement;
29 import com.helger.xml.microdom.MicroElement;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 @NotThreadSafe
54 public class PSLet implements IPSClonableElement <PSLet>
55 {
56 private String m_sName;
57 private String m_sValue;
58
59 public PSLet ()
60 {}
61
62 public boolean isValid (@Nonnull final IPSErrorHandler aErrorHandler)
63 {
64 if (StringHelper.hasNoText (m_sName))
65 {
66 aErrorHandler.error (this, "<let> has no 'name'");
67 return false;
68 }
69 if (StringHelper.hasNoText (m_sValue))
70 {
71 aErrorHandler.error (this, "<let> has no 'value'");
72 return false;
73 }
74 return true;
75 }
76
77 public void validateCompletely (@Nonnull final IPSErrorHandler aErrorHandler)
78 {
79 if (StringHelper.hasNoText (m_sName))
80 aErrorHandler.error (this, "<let> has no 'name'");
81 if (StringHelper.hasNoText (m_sValue))
82 aErrorHandler.error (this, "<let> has no 'value'");
83 }
84
85 public boolean isMinimal ()
86 {
87 return true;
88 }
89
90
91
92
93
94 public void setName (@Nullable final String sName)
95 {
96 m_sName = sName;
97 }
98
99
100
101
102 @Nullable
103 public String getName ()
104 {
105 return m_sName;
106 }
107
108
109
110
111
112 public void setValue (@Nullable final String sValue)
113 {
114 m_sValue = sValue;
115 }
116
117
118
119
120 @Nullable
121 public String getValue ()
122 {
123 return m_sValue;
124 }
125
126 @Nonnull
127 public IMicroElement getAsMicroElement ()
128 {
129 final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_LET);
130 ret.setAttribute (CSchematronXML.ATTR_NAME, m_sName);
131 ret.setAttribute (CSchematronXML.ATTR_VALUE, m_sValue);
132 return ret;
133 }
134
135 @Nonnull
136 public PSLet getClone ()
137 {
138 final PSLet/pure/model/PSLet.html#PSLet">PSLet ret = new PSLet ();
139 ret.setName (m_sName);
140 ret.setValue (m_sValue);
141 return ret;
142 }
143
144 @Override
145 public String toString ()
146 {
147 return new ToStringGenerator (this).appendIfNotNull ("name", m_sName)
148 .appendIfNotNull ("value", m_sValue)
149 .getToString ();
150 }
151 }