juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [11/51] [partial] incubator-juneau-website git commit: Improved URI resolution support.
Date Mon, 29 May 2017 22:24:13 GMT
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/57ce76c3/content/site/apidocs/src-html/org/apache/juneau/html/HtmlSerializerSession.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/html/HtmlSerializerSession.html
b/content/site/apidocs/src-html/org/apache/juneau/html/HtmlSerializerSession.html
index 4764b4c..587ce70 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/html/HtmlSerializerSession.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/html/HtmlSerializerSession.html
@@ -22,14 +22,14 @@
 <span class="sourceLineNo">014</span><a name="line.14"></a>
 <span class="sourceLineNo">015</span>import static org.apache.juneau.html.HtmlSerializerContext.*;<a
name="line.15"></a>
 <span class="sourceLineNo">016</span>import static org.apache.juneau.msgpack.MsgPackSerializerContext.*;<a
name="line.16"></a>
-<span class="sourceLineNo">017</span><a name="line.17"></a>
-<span class="sourceLineNo">018</span>import java.lang.reflect.*;<a name="line.18"></a>
-<span class="sourceLineNo">019</span>import java.util.*;<a name="line.19"></a>
-<span class="sourceLineNo">020</span>import java.util.regex.*;<a name="line.20"></a>
-<span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.juneau.*;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import org.apache.juneau.http.*;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.juneau.internal.*;<a
name="line.24"></a>
+<span class="sourceLineNo">017</span>import static org.apache.juneau.xml.XmlUtils.*;<a
name="line.17"></a>
+<span class="sourceLineNo">018</span><a name="line.18"></a>
+<span class="sourceLineNo">019</span>import java.lang.reflect.*;<a name="line.19"></a>
+<span class="sourceLineNo">020</span>import java.util.*;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.regex.*;<a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.juneau.*;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.juneau.http.*;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import org.apache.juneau.json.*;<a name="line.25"></a>
 <span class="sourceLineNo">026</span>import org.apache.juneau.xml.*;<a name="line.26"></a>
 <span class="sourceLineNo">027</span><a name="line.27"></a>
@@ -48,156 +48,146 @@
 <span class="sourceLineNo">040</span>      addBeanTypeProperties;<a name="line.40"></a>
 <span class="sourceLineNo">041</span>   private final Pattern urlPattern = Pattern.compile("http[s]?\\:\\/\\/.*");<a
name="line.41"></a>
 <span class="sourceLineNo">042</span>   private final Pattern labelPattern;<a
name="line.42"></a>
-<span class="sourceLineNo">043</span>   private final String absolutePathUriBase,
relativeUriBase;<a name="line.43"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
 <span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span><a name="line.45"></a>
-<span class="sourceLineNo">046</span>   @SuppressWarnings("hiding")<a name="line.46"></a>
-<span class="sourceLineNo">047</span>   enum AnchorText {<a name="line.47"></a>
-<span class="sourceLineNo">048</span>      PROPERTY_NAME, TO_STRING, URI, LAST_TOKEN,
URI_ANCHOR<a name="line.48"></a>
-<span class="sourceLineNo">049</span>   }<a name="line.49"></a>
-<span class="sourceLineNo">050</span><a name="line.50"></a>
-<span class="sourceLineNo">051</span>   /**<a name="line.51"></a>
-<span class="sourceLineNo">052</span>    * Create a new session using properties
specified in the context.<a name="line.52"></a>
-<span class="sourceLineNo">053</span>    *<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    * @param ctx The context creating this
session object.<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    *    The context contains all the configuration
settings for this object.<a name="line.55"></a>
-<span class="sourceLineNo">056</span>    * @param output The output object. 
See {@link JsonSerializerSession#getWriter()} for valid class types.<a name="line.56"></a>
-<span class="sourceLineNo">057</span>    * @param op The override properties.<a
name="line.57"></a>
-<span class="sourceLineNo">058</span>    *    These override any context properties
defined in the context.<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    * @param javaMethod The java method
that called this serializer, usually the method in a REST servlet.<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    * @param locale The session locale.<a
name="line.60"></a>
-<span class="sourceLineNo">061</span>    *    If &lt;jk&gt;null&lt;/jk&gt;,
then the locale defined on the context is used.<a name="line.61"></a>
-<span class="sourceLineNo">062</span>    * @param timeZone The session timezone.<a
name="line.62"></a>
-<span class="sourceLineNo">063</span>    *    If &lt;jk&gt;null&lt;/jk&gt;,
then the timezone defined on the context is used.<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    * @param mediaType The session media
type (e.g. &lt;js&gt;"application/json"&lt;/js&gt;).<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    * @param uriContext The URI context.<a
name="line.65"></a>
-<span class="sourceLineNo">066</span>    *    Identifies the current request
URI used for resolution of URIs to absolute or root-relative form.<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    */<a name="line.67"></a>
-<span class="sourceLineNo">068</span>   protected HtmlSerializerSession(HtmlSerializerContext
ctx, ObjectMap op, Object output, Method javaMethod, Locale locale, TimeZone timeZone, MediaType
mediaType, UriContext uriContext) {<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      super(ctx, op, output, javaMethod,
locale, timeZone, mediaType, uriContext);<a name="line.69"></a>
-<span class="sourceLineNo">070</span>      String labelParameter;<a name="line.70"></a>
-<span class="sourceLineNo">071</span>      if (op == null || op.isEmpty()) {<a
name="line.71"></a>
-<span class="sourceLineNo">072</span>         anchorText = Enum.valueOf(AnchorText.class,
ctx.uriAnchorText);<a name="line.72"></a>
-<span class="sourceLineNo">073</span>         detectLinksInStrings = ctx.detectLinksInStrings;<a
name="line.73"></a>
-<span class="sourceLineNo">074</span>         lookForLabelParameters = ctx.lookForLabelParameters;<a
name="line.74"></a>
-<span class="sourceLineNo">075</span>         labelParameter = ctx.labelParameter;<a
name="line.75"></a>
-<span class="sourceLineNo">076</span>         addKeyValueTableHeaders = ctx.addKeyValueTableHeaders;<a
name="line.76"></a>
-<span class="sourceLineNo">077</span>         addBeanTypeProperties = ctx.addBeanTypeProperties;<a
name="line.77"></a>
-<span class="sourceLineNo">078</span>      } else {<a name="line.78"></a>
-<span class="sourceLineNo">079</span>         anchorText = Enum.valueOf(AnchorText.class,
op.getString(HTML_uriAnchorText, ctx.uriAnchorText));<a name="line.79"></a>
-<span class="sourceLineNo">080</span>         detectLinksInStrings = op.getBoolean(HTML_detectLinksInStrings,
ctx.detectLinksInStrings);<a name="line.80"></a>
-<span class="sourceLineNo">081</span>         lookForLabelParameters = op.getBoolean(HTML_lookForLabelParameters,
ctx.lookForLabelParameters);<a name="line.81"></a>
-<span class="sourceLineNo">082</span>         labelParameter = op.getString(HTML_labelParameter,
ctx.labelParameter);<a name="line.82"></a>
-<span class="sourceLineNo">083</span>         addKeyValueTableHeaders = op.getBoolean(HTML_addKeyValueTableHeaders,
ctx.addKeyValueTableHeaders);<a name="line.83"></a>
-<span class="sourceLineNo">084</span>         addBeanTypeProperties = op.getBoolean(MSGPACK_addBeanTypeProperties,
ctx.addBeanTypeProperties);<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      }<a name="line.85"></a>
-<span class="sourceLineNo">086</span>      labelPattern = Pattern.compile("[\\?\\&amp;]"
+ Pattern.quote(labelParameter) + "=([^\\&amp;]*)");<a name="line.86"></a>
-<span class="sourceLineNo">087</span>      this.absolutePathUriBase = getAbsolutePathUriBase();<a
name="line.87"></a>
-<span class="sourceLineNo">088</span>      this.relativeUriBase = getRelativeUriBase();<a
name="line.88"></a>
-<span class="sourceLineNo">089</span>   }<a name="line.89"></a>
-<span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>   @Override /* XmlSerializerSession */<a
name="line.91"></a>
-<span class="sourceLineNo">092</span>   public HtmlWriter getWriter() throws
Exception {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>      Object output = getOutput();<a
name="line.93"></a>
-<span class="sourceLineNo">094</span>      if (output instanceof HtmlWriter)<a
name="line.94"></a>
-<span class="sourceLineNo">095</span>         return (HtmlWriter)output;<a
name="line.95"></a>
-<span class="sourceLineNo">096</span>      return new HtmlWriter(super.getWriter(),
isUseWhitespace(), isTrimStrings(), getQuoteChar(), getRelativeUriBase(), getAbsolutePathUriBase(),
getUriContext());<a name="line.96"></a>
-<span class="sourceLineNo">097</span>   }<a name="line.97"></a>
-<span class="sourceLineNo">098</span><a name="line.98"></a>
-<span class="sourceLineNo">099</span>   /**<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    * Returns &lt;jk&gt;true&lt;/jk&gt;
if the specified object is a URL.<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    *<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    * @param cm The ClassMeta of the object
being serialized.<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    * @param pMeta The property metadata
of the bean property of the object.  Can be &lt;jk&gt;null&lt;/jk&gt; if the
object isn't from a bean property.<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    * @param o The object.<a name="line.104"></a>
-<span class="sourceLineNo">105</span>    * @return &lt;jk&gt;true&lt;/jk&gt;
if the specified object is a URL.<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    */<a name="line.106"></a>
-<span class="sourceLineNo">107</span>   public boolean isUri(ClassMeta&lt;?&gt;
cm, BeanPropertyMeta pMeta, Object o) {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>      if (cm.isUri())<a name="line.108"></a>
-<span class="sourceLineNo">109</span>         return true;<a name="line.109"></a>
-<span class="sourceLineNo">110</span>      if (pMeta != null &amp;&amp;
pMeta.isUri())<a name="line.110"></a>
-<span class="sourceLineNo">111</span>         return true;<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      if (detectLinksInStrings &amp;&amp;
o instanceof CharSequence &amp;&amp; urlPattern.matcher(o.toString()).matches())<a
name="line.112"></a>
-<span class="sourceLineNo">113</span>         return true;<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      return false;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>   }<a name="line.115"></a>
-<span class="sourceLineNo">116</span><a name="line.116"></a>
-<span class="sourceLineNo">117</span>   /**<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    * Returns the anchor text to use for
the specified URL object.<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    *<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    * @param pMeta The property metadata
of the bean property of the object.  Can be &lt;jk&gt;null&lt;/jk&gt; if the
object isn't from a bean property.<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    * @param o The URL object.<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    * @return The anchor text to use for
the specified URL object.<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    */<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   public String getAnchorText(BeanPropertyMeta
pMeta, Object o) {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      String s;<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      if (lookForLabelParameters) {<a
name="line.126"></a>
-<span class="sourceLineNo">127</span>         s = o.toString();<a name="line.127"></a>
-<span class="sourceLineNo">128</span>         Matcher m = labelPattern.matcher(s);<a
name="line.128"></a>
-<span class="sourceLineNo">129</span>         if (m.find())<a name="line.129"></a>
-<span class="sourceLineNo">130</span>            return m.group(1);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      }<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      switch (anchorText) {<a name="line.132"></a>
-<span class="sourceLineNo">133</span>         case LAST_TOKEN:<a name="line.133"></a>
-<span class="sourceLineNo">134</span>            s = o.toString();<a name="line.134"></a>
-<span class="sourceLineNo">135</span>            if (s.indexOf('/') != -1)<a
name="line.135"></a>
-<span class="sourceLineNo">136</span>               s = s.substring(s.lastIndexOf('/')+1);<a
name="line.136"></a>
-<span class="sourceLineNo">137</span>            if (s.indexOf('?') != -1)<a
name="line.137"></a>
-<span class="sourceLineNo">138</span>               s = s.substring(0, s.indexOf('?'));<a
name="line.138"></a>
-<span class="sourceLineNo">139</span>            if (s.indexOf('#') != -1)<a
name="line.139"></a>
-<span class="sourceLineNo">140</span>               s = s.substring(0, s.indexOf('#'));<a
name="line.140"></a>
-<span class="sourceLineNo">141</span>            return s;<a name="line.141"></a>
-<span class="sourceLineNo">142</span>         case URI_ANCHOR:<a name="line.142"></a>
-<span class="sourceLineNo">143</span>            s = o.toString();<a name="line.143"></a>
-<span class="sourceLineNo">144</span>            if (s.indexOf('#') != -1)<a
name="line.144"></a>
-<span class="sourceLineNo">145</span>               s = s.substring(s.lastIndexOf('#')+1);<a
name="line.145"></a>
-<span class="sourceLineNo">146</span>            return s;<a name="line.146"></a>
-<span class="sourceLineNo">147</span>         case PROPERTY_NAME:<a name="line.147"></a>
-<span class="sourceLineNo">148</span>            return pMeta == null ? o.toString()
: pMeta.getName();<a name="line.148"></a>
-<span class="sourceLineNo">149</span>         case URI:<a name="line.149"></a>
-<span class="sourceLineNo">150</span>            s = o.toString();<a name="line.150"></a>
-<span class="sourceLineNo">151</span>            if (s.indexOf("://") == -1)
{<a name="line.151"></a>
-<span class="sourceLineNo">152</span>               if (StringUtils.startsWith(s,
'/')) {<a name="line.152"></a>
-<span class="sourceLineNo">153</span>                  s = absolutePathUriBase
+ s;<a name="line.153"></a>
-<span class="sourceLineNo">154</span>               } else {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>                  if (relativeUriBase !=
null) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>                     if (! relativeUriBase.equals("/"))<a
name="line.156"></a>
-<span class="sourceLineNo">157</span>                        s = relativeUriBase
+ "/" + s;<a name="line.157"></a>
-<span class="sourceLineNo">158</span>                     else<a name="line.158"></a>
-<span class="sourceLineNo">159</span>                        s = "/" + s;<a
name="line.159"></a>
-<span class="sourceLineNo">160</span>                  }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>               }<a name="line.161"></a>
-<span class="sourceLineNo">162</span>            }<a name="line.162"></a>
-<span class="sourceLineNo">163</span>            return s;<a name="line.163"></a>
-<span class="sourceLineNo">164</span>         default:<a name="line.164"></a>
-<span class="sourceLineNo">165</span>            return o.toString();<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      }<a name="line.166"></a>
-<span class="sourceLineNo">167</span>   }<a name="line.167"></a>
-<span class="sourceLineNo">168</span><a name="line.168"></a>
-<span class="sourceLineNo">169</span>   /**<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    * Returns the {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders}
setting value for this session.<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    *<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    * @return The {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders}
setting value for this session.<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    */<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   public final boolean isAddKeyValueTableHeaders()
{<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      return addKeyValueTableHeaders;<a
name="line.175"></a>
+<span class="sourceLineNo">045</span>   @SuppressWarnings("hiding")<a name="line.45"></a>
+<span class="sourceLineNo">046</span>   enum AnchorText {<a name="line.46"></a>
+<span class="sourceLineNo">047</span>      PROPERTY_NAME, TO_STRING, URI, LAST_TOKEN,
URI_ANCHOR, CONTEXT_RELATIVE, SERVLET_RELATIVE, PATH_RELATIVE<a name="line.47"></a>
+<span class="sourceLineNo">048</span>   }<a name="line.48"></a>
+<span class="sourceLineNo">049</span><a name="line.49"></a>
+<span class="sourceLineNo">050</span>   /**<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    * Create a new session using properties
specified in the context.<a name="line.51"></a>
+<span class="sourceLineNo">052</span>    *<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    * @param ctx The context creating this
session object.<a name="line.53"></a>
+<span class="sourceLineNo">054</span>    *    The context contains all the configuration
settings for this object.<a name="line.54"></a>
+<span class="sourceLineNo">055</span>    * @param output The output object. 
See {@link JsonSerializerSession#getWriter()} for valid class types.<a name="line.55"></a>
+<span class="sourceLineNo">056</span>    * @param op The override properties.<a
name="line.56"></a>
+<span class="sourceLineNo">057</span>    *    These override any context properties
defined in the context.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    * @param javaMethod The java method
that called this serializer, usually the method in a REST servlet.<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    * @param locale The session locale.<a
name="line.59"></a>
+<span class="sourceLineNo">060</span>    *    If &lt;jk&gt;null&lt;/jk&gt;,
then the locale defined on the context is used.<a name="line.60"></a>
+<span class="sourceLineNo">061</span>    * @param timeZone The session timezone.<a
name="line.61"></a>
+<span class="sourceLineNo">062</span>    *    If &lt;jk&gt;null&lt;/jk&gt;,
then the timezone defined on the context is used.<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    * @param mediaType The session media
type (e.g. &lt;js&gt;"application/json"&lt;/js&gt;).<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    * @param uriContext The URI context.<a
name="line.64"></a>
+<span class="sourceLineNo">065</span>    *    Identifies the current request
URI used for resolution of URIs to absolute or root-relative form.<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    */<a name="line.66"></a>
+<span class="sourceLineNo">067</span>   protected HtmlSerializerSession(HtmlSerializerContext
ctx, ObjectMap op, Object output, Method javaMethod, Locale locale, TimeZone timeZone, MediaType
mediaType, UriContext uriContext) {<a name="line.67"></a>
+<span class="sourceLineNo">068</span>      super(ctx, op, output, javaMethod,
locale, timeZone, mediaType, uriContext);<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      String labelParameter;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      if (op == null || op.isEmpty()) {<a
name="line.70"></a>
+<span class="sourceLineNo">071</span>         anchorText = Enum.valueOf(AnchorText.class,
ctx.uriAnchorText);<a name="line.71"></a>
+<span class="sourceLineNo">072</span>         detectLinksInStrings = ctx.detectLinksInStrings;<a
name="line.72"></a>
+<span class="sourceLineNo">073</span>         lookForLabelParameters = ctx.lookForLabelParameters;<a
name="line.73"></a>
+<span class="sourceLineNo">074</span>         labelParameter = ctx.labelParameter;<a
name="line.74"></a>
+<span class="sourceLineNo">075</span>         addKeyValueTableHeaders = ctx.addKeyValueTableHeaders;<a
name="line.75"></a>
+<span class="sourceLineNo">076</span>         addBeanTypeProperties = ctx.addBeanTypeProperties;<a
name="line.76"></a>
+<span class="sourceLineNo">077</span>      } else {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>         anchorText = Enum.valueOf(AnchorText.class,
op.getString(HTML_uriAnchorText, ctx.uriAnchorText));<a name="line.78"></a>
+<span class="sourceLineNo">079</span>         detectLinksInStrings = op.getBoolean(HTML_detectLinksInStrings,
ctx.detectLinksInStrings);<a name="line.79"></a>
+<span class="sourceLineNo">080</span>         lookForLabelParameters = op.getBoolean(HTML_lookForLabelParameters,
ctx.lookForLabelParameters);<a name="line.80"></a>
+<span class="sourceLineNo">081</span>         labelParameter = op.getString(HTML_labelParameter,
ctx.labelParameter);<a name="line.81"></a>
+<span class="sourceLineNo">082</span>         addKeyValueTableHeaders = op.getBoolean(HTML_addKeyValueTableHeaders,
ctx.addKeyValueTableHeaders);<a name="line.82"></a>
+<span class="sourceLineNo">083</span>         addBeanTypeProperties = op.getBoolean(MSGPACK_addBeanTypeProperties,
ctx.addBeanTypeProperties);<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      }<a name="line.84"></a>
+<span class="sourceLineNo">085</span>      labelPattern = Pattern.compile("[\\?\\&amp;]"
+ Pattern.quote(labelParameter) + "=([^\\&amp;]*)");<a name="line.85"></a>
+<span class="sourceLineNo">086</span>   }<a name="line.86"></a>
+<span class="sourceLineNo">087</span><a name="line.87"></a>
+<span class="sourceLineNo">088</span>   @Override /* XmlSerializerSession */<a
name="line.88"></a>
+<span class="sourceLineNo">089</span>   public HtmlWriter getWriter() throws
Exception {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>      Object output = getOutput();<a
name="line.90"></a>
+<span class="sourceLineNo">091</span>      if (output instanceof HtmlWriter)<a
name="line.91"></a>
+<span class="sourceLineNo">092</span>         return (HtmlWriter)output;<a
name="line.92"></a>
+<span class="sourceLineNo">093</span>      return new HtmlWriter(super.getWriter(),
isUseWhitespace(), isTrimStrings(), getQuoteChar(), getUriResolver());<a name="line.93"></a>
+<span class="sourceLineNo">094</span>   }<a name="line.94"></a>
+<span class="sourceLineNo">095</span><a name="line.95"></a>
+<span class="sourceLineNo">096</span>   /**<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    * Returns &lt;jk&gt;true&lt;/jk&gt;
if the specified object is a URL.<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    *<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    * @param cm The ClassMeta of the object
being serialized.<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    * @param pMeta The property metadata
of the bean property of the object.  Can be &lt;jk&gt;null&lt;/jk&gt; if the
object isn't from a bean property.<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    * @param o The object.<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    * @return &lt;jk&gt;true&lt;/jk&gt;
if the specified object is a URL.<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    */<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   public boolean isUri(ClassMeta&lt;?&gt;
cm, BeanPropertyMeta pMeta, Object o) {<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      if (cm.isUri())<a name="line.105"></a>
+<span class="sourceLineNo">106</span>         return true;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      if (pMeta != null &amp;&amp;
pMeta.isUri())<a name="line.107"></a>
+<span class="sourceLineNo">108</span>         return true;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      if (detectLinksInStrings &amp;&amp;
o instanceof CharSequence &amp;&amp; urlPattern.matcher(o.toString()).matches())<a
name="line.109"></a>
+<span class="sourceLineNo">110</span>         return true;<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      return false;<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   }<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>   /**<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    * Returns the anchor text to use for
the specified URL object.<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    *<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    * @param pMeta The property metadata
of the bean property of the object.  Can be &lt;jk&gt;null&lt;/jk&gt; if the
object isn't from a bean property.<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    * @param o The URL object.<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    * @return The anchor text to use for
the specified URL object.<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    */<a name="line.120"></a>
+<span class="sourceLineNo">121</span>   public String getAnchorText(BeanPropertyMeta
pMeta, Object o) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      String s = o.toString();<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      if (lookForLabelParameters) {<a
name="line.123"></a>
+<span class="sourceLineNo">124</span>         Matcher m = labelPattern.matcher(s);<a
name="line.124"></a>
+<span class="sourceLineNo">125</span>         if (m.find())<a name="line.125"></a>
+<span class="sourceLineNo">126</span>            return urlDecode(m.group(1));<a
name="line.126"></a>
+<span class="sourceLineNo">127</span>      }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      switch (anchorText) {<a name="line.128"></a>
+<span class="sourceLineNo">129</span>         case LAST_TOKEN:<a name="line.129"></a>
+<span class="sourceLineNo">130</span>            s = resolveUri(s);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>            if (s.indexOf('/') != -1)<a
name="line.131"></a>
+<span class="sourceLineNo">132</span>               s = s.substring(s.lastIndexOf('/')+1);<a
name="line.132"></a>
+<span class="sourceLineNo">133</span>            if (s.indexOf('?') != -1)<a
name="line.133"></a>
+<span class="sourceLineNo">134</span>               s = s.substring(0, s.indexOf('?'));<a
name="line.134"></a>
+<span class="sourceLineNo">135</span>            if (s.indexOf('#') != -1)<a
name="line.135"></a>
+<span class="sourceLineNo">136</span>               s = s.substring(0, s.indexOf('#'));<a
name="line.136"></a>
+<span class="sourceLineNo">137</span>            if (s.isEmpty())<a name="line.137"></a>
+<span class="sourceLineNo">138</span>               s = "/";<a name="line.138"></a>
+<span class="sourceLineNo">139</span>            return urlDecode(s);<a name="line.139"></a>
+<span class="sourceLineNo">140</span>         case URI_ANCHOR:<a name="line.140"></a>
+<span class="sourceLineNo">141</span>            if (s.indexOf('#') != -1)<a
name="line.141"></a>
+<span class="sourceLineNo">142</span>               s = s.substring(s.lastIndexOf('#')+1);<a
name="line.142"></a>
+<span class="sourceLineNo">143</span>            return urlDecode(s);<a name="line.143"></a>
+<span class="sourceLineNo">144</span>         case PROPERTY_NAME:<a name="line.144"></a>
+<span class="sourceLineNo">145</span>            return pMeta == null ? s : pMeta.getName();<a
name="line.145"></a>
+<span class="sourceLineNo">146</span>         case URI:<a name="line.146"></a>
+<span class="sourceLineNo">147</span>            return resolveUri(s);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>         case CONTEXT_RELATIVE:<a name="line.148"></a>
+<span class="sourceLineNo">149</span>            return relativizeUri("context:/",
s);<a name="line.149"></a>
+<span class="sourceLineNo">150</span>         case SERVLET_RELATIVE:<a name="line.150"></a>
+<span class="sourceLineNo">151</span>            return relativizeUri("servlet:/",
s);<a name="line.151"></a>
+<span class="sourceLineNo">152</span>         case PATH_RELATIVE:<a name="line.152"></a>
+<span class="sourceLineNo">153</span>            return relativizeUri("request:/",
s);<a name="line.153"></a>
+<span class="sourceLineNo">154</span>         default /* TO_STRING */:<a name="line.154"></a>
+<span class="sourceLineNo">155</span>            return s;<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      }<a name="line.156"></a>
+<span class="sourceLineNo">157</span>   }<a name="line.157"></a>
+<span class="sourceLineNo">158</span><a name="line.158"></a>
+<span class="sourceLineNo">159</span>   /**<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    * Returns the {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders}
setting value for this session.<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    *<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    * @return The {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders}
setting value for this session.<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    */<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   public final boolean isAddKeyValueTableHeaders()
{<a name="line.164"></a>
+<span class="sourceLineNo">165</span>      return addKeyValueTableHeaders;<a
name="line.165"></a>
+<span class="sourceLineNo">166</span>   }<a name="line.166"></a>
+<span class="sourceLineNo">167</span><a name="line.167"></a>
+<span class="sourceLineNo">168</span>   /**<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    * Returns the {@link HtmlSerializerContext#HTML_addBeanTypeProperties}
setting value for this session.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    *<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    * @return The {@link HtmlSerializerContext#HTML_addBeanTypeProperties}
setting value for this session.<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>   @Override /* SerializerSession */<a
name="line.173"></a>
+<span class="sourceLineNo">174</span>   public final boolean isAddBeanTypeProperties()
{<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      return addBeanTypeProperties;<a
name="line.175"></a>
 <span class="sourceLineNo">176</span>   }<a name="line.176"></a>
 <span class="sourceLineNo">177</span><a name="line.177"></a>
-<span class="sourceLineNo">178</span>   /**<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    * Returns the {@link HtmlSerializerContext#HTML_addBeanTypeProperties}
setting value for this session.<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    *<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    * @return The {@link HtmlSerializerContext#HTML_addBeanTypeProperties}
setting value for this session.<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    */<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   @Override /* SerializerSession */<a
name="line.183"></a>
-<span class="sourceLineNo">184</span>   public final boolean isAddBeanTypeProperties()
{<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      return addBeanTypeProperties;<a
name="line.185"></a>
-<span class="sourceLineNo">186</span>   }<a name="line.186"></a>
-<span class="sourceLineNo">187</span><a name="line.187"></a>
-<span class="sourceLineNo">188</span>   @Override /* XmlSerializer */<a name="line.188"></a>
-<span class="sourceLineNo">189</span>   public boolean isHtmlMode() {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      return true;<a name="line.190"></a>
-<span class="sourceLineNo">191</span>   }<a name="line.191"></a>
-<span class="sourceLineNo">192</span>}<a name="line.192"></a>
+<span class="sourceLineNo">178</span>   @Override /* XmlSerializer */<a name="line.178"></a>
+<span class="sourceLineNo">179</span>   public boolean isHtmlMode() {<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      return true;<a name="line.180"></a>
+<span class="sourceLineNo">181</span>   }<a name="line.181"></a>
+<span class="sourceLineNo">182</span>}<a name="line.182"></a>
 
 
 


Mime
View raw message