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 @NotThreadSafe
41 public class PSInclude implements IPSElement
42 {
43 private String m_sHref;
44
45 public PSInclude ()
46 {}
47
48 public boolean isValid (@Nonnull final IPSErrorHandler aErrorHandler)
49 {
50 if (StringHelper.hasNoText (m_sHref))
51 {
52 aErrorHandler.error (this, "<include> has no 'href'");
53 return false;
54 }
55 return true;
56 }
57
58 public void validateCompletely (@Nonnull final IPSErrorHandler aErrorHandler)
59 {
60 if (StringHelper.hasNoText (m_sHref))
61 aErrorHandler.error (this, "<include> has no 'href'");
62 }
63
64 public boolean isMinimal ()
65 {
66 return false;
67 }
68
69
70
71
72
73 public void setHref (@Nullable final String sHref)
74 {
75 m_sHref = sHref;
76 }
77
78
79
80
81 @Nullable
82 public String getHref ()
83 {
84 return m_sHref;
85 }
86
87 @Nonnull
88 public IMicroElement getAsMicroElement ()
89 {
90 final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_INCLUDE);
91 ret.setAttribute (CSchematronXML.ATTR_HREF, m_sHref);
92 return ret;
93 }
94
95 @Override
96 public String toString ()
97 {
98 return new ToStringGenerator (this).appendIfNotNull ("href", m_sHref).toString ();
99 }
100 }