http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/org/apache/juneau/utils/StringObject.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/org/apache/juneau/utils/StringObject.html b/content/site/apidocs/org/apache/juneau/utils/StringObject.html new file mode 100644 index 0000000..3382747 --- /dev/null +++ b/content/site/apidocs/org/apache/juneau/utils/StringObject.html @@ -0,0 +1,430 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>StringObject (Apache Juneau (incubating) 6.1.1-incubating-SNAPSHOT)</title> +<link rel="stylesheet" type="text/css" href="../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="StringObject (Apache Juneau (incubating) 6.1.1-incubating-SNAPSHOT)"; + } + } + catch(err) { + } +//--> +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10}; +var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; +var altColor = "altColor"; +var rowColor = "rowColor"; +var tableTab = "tableTab"; +var activeTableTab = "activeTableTab"; +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../overview-summary.html">Overview</a></li> +<li><a href="package-summary.html">Package</a></li> +<li class="navBarCell1Rev">Class</li> +<li><a href="package-tree.html">Tree</a></li> +<li><a href="../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../index-all.html">Index</a></li> +<li><a href="../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li><a href="../../../../org/apache/juneau/utils/StringMessage.html" title="class in org.apache.juneau.utils"><span class="typeNameLink">Prev Class</span></a></li> +<li><a href="../../../../org/apache/juneau/utils/ZipFileList.html" title="class in org.apache.juneau.utils"><span class="typeNameLink">Next Class</span></a></li> +</ul> +<ul class="navList"> +<li><a href="../../../../index.html?org/apache/juneau/utils/StringObject.html" target="_top">Frames</a></li> +<li><a href="StringObject.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<div> +<ul class="subNavList"> +<li>Summary: </li> +<li>Nested | </li> +<li>Field | </li> +<li><a href="#constructor.summary">Constr</a> | </li> +<li><a href="#method.summary">Method</a></li> +</ul> +<ul class="subNavList"> +<li>Detail: </li> +<li>Field | </li> +<li><a href="#constructor.detail">Constr</a> | </li> +<li><a href="#method.detail">Method</a></li> +</ul> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<!-- ======== START OF CLASS DATA ======== --> +<div class="header"> +<div class="subTitle">org.apache.juneau.utils</div> +<h2 title="Class StringObject" class="title">Class StringObject</h2> +</div> +<div class="contentContainer"> +<ul class="inheritance"> +<li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> +<li> +<ul class="inheritance"> +<li>org.apache.juneau.utils.StringObject</li> +</ul> +</li> +</ul> +<div class="description"> +<ul class="blockList"> +<li class="blockList"> +<dl> +<dt>All Implemented Interfaces:</dt> +<dd><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a>, <a href="../../../../org/apache/juneau/Writable.html" title="interface in org.apache.juneau">Writable</a></dd> +</dl> +<hr> +<br> +<pre>public class <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.34">StringObject</a> +extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> +implements <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a>, <a href="../../../../org/apache/juneau/Writable.html" title="interface in org.apache.juneau">Writable</a></pre> +<div class="block">A serializer/object pair used for delayed object serialization. + <p> + Useful in certain conditions such as logging when you don't want to needlessly serialize objects. + <p> + Instances of this method are created by the <a href="../../../../org/apache/juneau/serializer/WriterSerializer.html#toStringObject-java.lang.Object-"><code>WriterSerializer.toStringObject(Object)</code></a> method. + + <h5 class='section'>Example:</h5> + <p class='bcode'> + <jc>// The POJO will not be serialized unless DEBUG is enabled.</jc> + logger.log(<jsf>DEBUG</jsf>, <js>"Object contents are: {0}"</js>, JsonSerializer.<jsf>DEFAULT</jsf>.toObjectString(myPojo)); + </p></div> +</li> +</ul> +</div> +<div class="summary"> +<ul class="blockList"> +<li class="blockList"> +<!-- ======== CONSTRUCTOR SUMMARY ======== --> +<ul class="blockList"> +<li class="blockList"><a name="constructor.summary"> +<!-- --> +</a> +<h3>Constructor Summary</h3> +<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> +<caption><span>Constructors</span><span class="tabEnd"> </span></caption> +<tr> +<th class="colOne" scope="col">Constructor and Description</th> +</tr> +<tr class="altColor"> +<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#StringObject-java.lang.Object-">StringObject</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> o)</code> +<div class="block">Constructor with default serializer <a href="../../../../org/apache/juneau/json/JsonSerializer.html#DEFAULT_LAX"><code>JsonSerializer.DEFAULT_LAX</code></a></div> +</td> +</tr> +<tr class="rowColor"> +<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#StringObject-org.apache.juneau.serializer.WriterSerializer-java.lang.Object-">StringObject</a></span>(<a href="../../../../org/apache/juneau/serializer/WriterSerializer.html" title="class in org.apache.juneau.serializer">WriterSerializer</a> s, + <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> o)</code> +<div class="block">Constructor.</div> +</td> +</tr> +</table> +</li> +</ul> +<!-- ========== METHOD SUMMARY =========== --> +<ul class="blockList"> +<li class="blockList"><a name="method.summary"> +<!-- --> +</a> +<h3>Method Summary</h3> +<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> +<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> +<tr> +<th class="colFirst" scope="col">Modifier and Type</th> +<th class="colLast" scope="col">Method and Description</th> +</tr> +<tr id="i0" class="altColor"> +<td class="colFirst"><code>char</code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#charAt-int-">charAt</a></span>(int index)</code> </td> +</tr> +<tr id="i1" class="rowColor"> +<td class="colFirst"><code><a href="../../../../org/apache/juneau/MediaType.html" title="class in org.apache.juneau">MediaType</a></code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#getMediaType--">getMediaType</a></span>()</code> +<div class="block">Returns the serialized media type for this resource (e.g.</div> +</td> +</tr> +<tr id="i2" class="altColor"> +<td class="colFirst"><code>int</code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#length--">length</a></span>()</code> </td> +</tr> +<tr id="i3" class="rowColor"> +<td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#subSequence-int-int-">subSequence</a></span>(int start, + int end)</code> </td> +</tr> +<tr id="i4" class="altColor"> +<td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#toString--">toString</a></span>()</code> </td> +</tr> +<tr id="i5" class="rowColor"> +<td class="colFirst"><code>void</code></td> +<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/juneau/utils/StringObject.html#writeTo-java.io.Writer-">writeTo</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/Writer.html?is-external=true" title="class or interface in java.io">Writer</a> w)</code> +<div class="block">Serialize this object to the specified writer.</div> +</td> +</tr> +</table> +<ul class="blockList"> +<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> +<!-- --> +</a> +<h3>Methods inherited from class java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> +<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang /Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li> +</ul> +<ul class="blockList"> +<li class="blockList"><a name="methods.inherited.from.class.java.lang.CharSequence"> +<!-- --> +</a> +<h3>Methods inherited from interface java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></h3> +<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#chars--" title="class or interface in java.lang">chars</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#codePoints--" title="class or interface in java.lang">codePoints</a></code></li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +<div class="details"> +<ul class="blockList"> +<li class="blockList"> +<!-- ========= CONSTRUCTOR DETAIL ======== --> +<ul class="blockList"> +<li class="blockList"><a name="constructor.detail"> +<!-- --> +</a> +<h3>Constructor Detail</h3> +<a name="StringObject-org.apache.juneau.serializer.WriterSerializer-java.lang.Object-"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>StringObject</h4> +<pre>public <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.45">StringObject</a>(<a href="../../../../org/apache/juneau/serializer/WriterSerializer.html" title="class in org.apache.juneau.serializer">WriterSerializer</a> s, + <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> o)</pre> +<div class="block">Constructor.</div> +<dl> +<dt><span class="paramLabel">Parameters:</span></dt> +<dd><code>s</code> - The serializer to use to serialize the object.</dd> +<dd><code>o</code> - The object to be serialized.</dd> +</dl> +</li> +</ul> +<a name="StringObject-java.lang.Object-"> +<!-- --> +</a> +<ul class="blockListLast"> +<li class="blockList"> +<h4>StringObject</h4> +<pre>public <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.54">StringObject</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> o)</pre> +<div class="block">Constructor with default serializer <a href="../../../../org/apache/juneau/json/JsonSerializer.html#DEFAULT_LAX"><code>JsonSerializer.DEFAULT_LAX</code></a></div> +<dl> +<dt><span class="paramLabel">Parameters:</span></dt> +<dd><code>o</code> - The object to be serialized.</dd> +</dl> +</li> +</ul> +</li> +</ul> +<!-- ============ METHOD DETAIL ========== --> +<ul class="blockList"> +<li class="blockList"><a name="method.detail"> +<!-- --> +</a> +<h3>Method Detail</h3> +<a name="toString--"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>toString</h4> +<pre>public <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.59">toString</a>()</pre> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#toString--" title="class or interface in java.lang">toString</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></code></dd> +<dt><span class="overrideSpecifyLabel">Overrides:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a></code> in class <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd> +</dl> +</li> +</ul> +<a name="length--"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>length</h4> +<pre>public int <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.66">length</a>()</pre> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#length--" title="class or interface in java.lang">length</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></code></dd> +</dl> +</li> +</ul> +<a name="charAt-int-"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>charAt</h4> +<pre>public char <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.71">charAt</a>(int index)</pre> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#charAt-int-" title="class or interface in java.lang">charAt</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></code></dd> +</dl> +</li> +</ul> +<a name="subSequence-int-int-"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>subSequence</h4> +<pre>public <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a> <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.76">subSequence</a>(int start, + int end)</pre> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true#subSequence-int-int-" title="class or interface in java.lang">subSequence</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</a></code></dd> +</dl> +</li> +</ul> +<a name="writeTo-java.io.Writer-"> +<!-- --> +</a> +<ul class="blockList"> +<li class="blockList"> +<h4>writeTo</h4> +<pre>public void <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.81">writeTo</a>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/Writer.html?is-external=true" title="class or interface in java.io">Writer</a> w) + throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre> +<div class="block"><span class="descfrmTypeLabel">Description copied from interface: <code><a href="../../../../org/apache/juneau/Writable.html#writeTo-java.io.Writer-">Writable</a></code></span></div> +<div class="block">Serialize this object to the specified writer.</div> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="../../../../org/apache/juneau/Writable.html#writeTo-java.io.Writer-">writeTo</a></code> in interface <code><a href="../../../../org/apache/juneau/Writable.html" title="interface in org.apache.juneau">Writable</a></code></dd> +<dt><span class="paramLabel">Parameters:</span></dt> +<dd><code>w</code> - The writer to write to.</dd> +<dt><span class="throwsLabel">Throws:</span></dt> +<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code></dd> +</dl> +</li> +</ul> +<a name="getMediaType--"> +<!-- --> +</a> +<ul class="blockListLast"> +<li class="blockList"> +<h4>getMediaType</h4> +<pre>public <a href="../../../../org/apache/juneau/MediaType.html" title="class in org.apache.juneau">MediaType</a> <a href="../../../../src-html/org/apache/juneau/utils/StringObject.html#line.90">getMediaType</a>()</pre> +<div class="block"><span class="descfrmTypeLabel">Description copied from interface: <code><a href="../../../../org/apache/juneau/Writable.html#getMediaType--">Writable</a></code></span></div> +<div class="block">Returns the serialized media type for this resource (e.g. <js>"text/html"</js>)</div> +<dl> +<dt><span class="overrideSpecifyLabel">Specified by:</span></dt> +<dd><code><a href="../../../../org/apache/juneau/Writable.html#getMediaType--">getMediaType</a></code> in interface <code><a href="../../../../org/apache/juneau/Writable.html" title="interface in org.apache.juneau">Writable</a></code></dd> +<dt><span class="returnLabel">Returns:</span></dt> +<dd>The media type, or <jk>null</jk> if the media type is not known.</dd> +</dl> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +</div> +<!-- ========= END OF CLASS DATA ========= --> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../overview-summary.html">Overview</a></li> +<li><a href="package-summary.html">Package</a></li> +<li class="navBarCell1Rev">Class</li> +<li><a href="package-tree.html">Tree</a></li> +<li><a href="../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../index-all.html">Index</a></li> +<li><a href="../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li><a href="../../../../org/apache/juneau/utils/StringMessage.html" title="class in org.apache.juneau.utils"><span class="typeNameLink">Prev Class</span></a></li> +<li><a href="../../../../org/apache/juneau/utils/ZipFileList.html" title="class in org.apache.juneau.utils"><span class="typeNameLink">Next Class</span></a></li> +</ul> +<ul class="navList"> +<li><a href="../../../../index.html?org/apache/juneau/utils/StringObject.html" target="_top">Frames</a></li> +<li><a href="StringObject.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<div> +<ul class="subNavList"> +<li>Summary: </li> +<li>Nested | </li> +<li>Field | </li> +<li><a href="#constructor.summary">Constr</a> | </li> +<li><a href="#method.summary">Method</a></li> +</ul> +<ul class="subNavList"> +<li>Detail: </li> +<li>Field | </li> +<li><a href="#constructor.detail">Constr</a> | </li> +<li><a href="#method.detail">Method</a></li> +</ul> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +<p class="legalCopy"><small>Copyright © 2017 <a href="http://www.apache.org/">Apache</a>. All rights reserved.</small></p> +</body> +</html>
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/src-html/org/apache/juneau/ini/ConfigFileBuilder.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/ini/ConfigFileBuilder.html b/content/site/apidocs/src-html/org/apache/juneau/ini/ConfigFileBuilder.html new file mode 100644 index 0000000..9e77fe8 --- /dev/null +++ b/content/site/apidocs/src-html/org/apache/juneau/ini/ConfigFileBuilder.html @@ -0,0 +1,383 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>// ***************************************************************************************************************************<a name="line.1"></a> +<span class="sourceLineNo">002</span>// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *<a name="line.2"></a> +<span class="sourceLineNo">003</span>// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *<a name="line.3"></a> +<span class="sourceLineNo">004</span>// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *<a name="line.4"></a> +<span class="sourceLineNo">005</span>// * with the License. You may obtain a copy of the License at *<a name="line.5"></a> +<span class="sourceLineNo">006</span>// * *<a name="line.6"></a> +<span class="sourceLineNo">007</span>// * http://www.apache.org/licenses/LICENSE-2.0 *<a name="line.7"></a> +<span class="sourceLineNo">008</span>// * *<a name="line.8"></a> +<span class="sourceLineNo">009</span>// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *<a name="line.9"></a> +<span class="sourceLineNo">010</span>// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *<a name="line.10"></a> +<span class="sourceLineNo">011</span>// * specific language governing permissions and limitations under the License. *<a name="line.11"></a> +<span class="sourceLineNo">012</span>// ***************************************************************************************************************************<a name="line.12"></a> +<span class="sourceLineNo">013</span>package org.apache.juneau.ini;<a name="line.13"></a> +<span class="sourceLineNo">014</span><a name="line.14"></a> +<span class="sourceLineNo">015</span>import static org.apache.juneau.ini.ConfigFileFormat.*;<a name="line.15"></a> +<span class="sourceLineNo">016</span><a name="line.16"></a> +<span class="sourceLineNo">017</span>import java.io.*;<a name="line.17"></a> +<span class="sourceLineNo">018</span>import java.nio.charset.*;<a name="line.18"></a> +<span class="sourceLineNo">019</span>import java.util.*;<a name="line.19"></a> +<span class="sourceLineNo">020</span>import org.apache.juneau.internal.*;<a name="line.20"></a> +<span class="sourceLineNo">021</span>import org.apache.juneau.json.*;<a name="line.21"></a> +<span class="sourceLineNo">022</span>import org.apache.juneau.parser.*;<a name="line.22"></a> +<span class="sourceLineNo">023</span>import org.apache.juneau.serializer.*;<a name="line.23"></a> +<span class="sourceLineNo">024</span>import org.apache.juneau.utils.*;<a name="line.24"></a> +<span class="sourceLineNo">025</span><a name="line.25"></a> +<span class="sourceLineNo">026</span>/**<a name="line.26"></a> +<span class="sourceLineNo">027</span> * Builder for creating instances of {@link ConfigFile ConfigFiles}.<a name="line.27"></a> +<span class="sourceLineNo">028</span> *<a name="line.28"></a> +<span class="sourceLineNo">029</span> * <h5 class='section'>Example:</h5><a name="line.29"></a> +<span class="sourceLineNo">030</span> * <p class='bcode'><a name="line.30"></a> +<span class="sourceLineNo">031</span> * ConfigFile cf = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>);<a name="line.31"></a> +<span class="sourceLineNo">032</span> * String setting = cf.get(<js>"MySection/mysetting"</js>);<a name="line.32"></a> +<span class="sourceLineNo">033</span> * </p><a name="line.33"></a> +<span class="sourceLineNo">034</span> */<a name="line.34"></a> +<span class="sourceLineNo">035</span>@SuppressWarnings("hiding")<a name="line.35"></a> +<span class="sourceLineNo">036</span>public class ConfigFileBuilder {<a name="line.36"></a> +<span class="sourceLineNo">037</span><a name="line.37"></a> +<span class="sourceLineNo">038</span> private WriterSerializer serializer = JsonSerializer.DEFAULT_LAX;<a name="line.38"></a> +<span class="sourceLineNo">039</span> private ReaderParser parser = JsonParser.DEFAULT;<a name="line.39"></a> +<span class="sourceLineNo">040</span> private Encoder encoder = new XorEncoder();<a name="line.40"></a> +<span class="sourceLineNo">041</span> private boolean readOnly = false, createIfNotExists = false;<a name="line.41"></a> +<span class="sourceLineNo">042</span> private Charset charset = Charset.defaultCharset();<a name="line.42"></a> +<span class="sourceLineNo">043</span> private List<File> searchPaths = new AList<File>().append(new File("."));<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> * Specify the encoder to use for encoded config file entries (e.g. <js>"mySecret*={...}"</js>).<a name="line.46"></a> +<span class="sourceLineNo">047</span> * <p><a name="line.47"></a> +<span class="sourceLineNo">048</span> * The default value for this setting is an instance of {@link XorEncoder}.<a name="line.48"></a> +<span class="sourceLineNo">049</span> *<a name="line.49"></a> +<span class="sourceLineNo">050</span> * @param encoder The new value for this setting.<a name="line.50"></a> +<span class="sourceLineNo">051</span> * @return This object (for method chaining).<a name="line.51"></a> +<span class="sourceLineNo">052</span> */<a name="line.52"></a> +<span class="sourceLineNo">053</span> public ConfigFileBuilder encoder(Encoder encoder) {<a name="line.53"></a> +<span class="sourceLineNo">054</span> this.encoder = encoder;<a name="line.54"></a> +<span class="sourceLineNo">055</span> return this;<a name="line.55"></a> +<span class="sourceLineNo">056</span> }<a name="line.56"></a> +<span class="sourceLineNo">057</span><a name="line.57"></a> +<span class="sourceLineNo">058</span> /**<a name="line.58"></a> +<span class="sourceLineNo">059</span> * Specify the serializer to use for serializing POJOs when using {@link ConfigFile#put(String, Object)}.<a name="line.59"></a> +<span class="sourceLineNo">060</span> * <p><a name="line.60"></a> +<span class="sourceLineNo">061</span> * The default value for this setting is {@link JsonSerializer#DEFAULT_LAX}.<a name="line.61"></a> +<span class="sourceLineNo">062</span> *<a name="line.62"></a> +<span class="sourceLineNo">063</span> * @param serializer The new value for this setting.<a name="line.63"></a> +<span class="sourceLineNo">064</span> * @return This object (for method chaining).<a name="line.64"></a> +<span class="sourceLineNo">065</span> */<a name="line.65"></a> +<span class="sourceLineNo">066</span> public ConfigFileBuilder serializer(WriterSerializer serializer) {<a name="line.66"></a> +<span class="sourceLineNo">067</span> this.serializer = serializer;<a name="line.67"></a> +<span class="sourceLineNo">068</span> return this;<a name="line.68"></a> +<span class="sourceLineNo">069</span> }<a name="line.69"></a> +<span class="sourceLineNo">070</span><a name="line.70"></a> +<span class="sourceLineNo">071</span> /**<a name="line.71"></a> +<span class="sourceLineNo">072</span> * Specify the parser to use for parsing POJOs when using {@link ConfigFile#getObject(Class,String)}.<a name="line.72"></a> +<span class="sourceLineNo">073</span> * <p><a name="line.73"></a> +<span class="sourceLineNo">074</span> * The default value for this setting is {@link JsonParser#DEFAULT}<a name="line.74"></a> +<span class="sourceLineNo">075</span> *<a name="line.75"></a> +<span class="sourceLineNo">076</span> * @param parser The new value for this setting.<a name="line.76"></a> +<span class="sourceLineNo">077</span> * @return This object (for method chaining).<a name="line.77"></a> +<span class="sourceLineNo">078</span> */<a name="line.78"></a> +<span class="sourceLineNo">079</span> public ConfigFileBuilder parser(ReaderParser parser) {<a name="line.79"></a> +<span class="sourceLineNo">080</span> this.parser = parser;<a name="line.80"></a> +<span class="sourceLineNo">081</span> return this;<a name="line.81"></a> +<span class="sourceLineNo">082</span> }<a name="line.82"></a> +<span class="sourceLineNo">083</span><a name="line.83"></a> +<span class="sourceLineNo">084</span> /**<a name="line.84"></a> +<span class="sourceLineNo">085</span> * Specify the config file character encoding.<a name="line.85"></a> +<span class="sourceLineNo">086</span> * <p><a name="line.86"></a> +<span class="sourceLineNo">087</span> * The default value for this setting is {@link Charset#defaultCharset()}.<a name="line.87"></a> +<span class="sourceLineNo">088</span> *<a name="line.88"></a> +<span class="sourceLineNo">089</span> * @param charset The new value for this setting.<a name="line.89"></a> +<span class="sourceLineNo">090</span> * @return This object (for method chaining).<a name="line.90"></a> +<span class="sourceLineNo">091</span> */<a name="line.91"></a> +<span class="sourceLineNo">092</span> public ConfigFileBuilder charset(Charset charset) {<a name="line.92"></a> +<span class="sourceLineNo">093</span> this.charset = charset;<a name="line.93"></a> +<span class="sourceLineNo">094</span> return this;<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> /**<a name="line.97"></a> +<span class="sourceLineNo">098</span> * Specify the search paths for config files.<a name="line.98"></a> +<span class="sourceLineNo">099</span> * <p><a name="line.99"></a> +<span class="sourceLineNo">100</span> * Can contain relative or absolute paths.<a name="line.100"></a> +<span class="sourceLineNo">101</span> * <p><a name="line.101"></a> +<span class="sourceLineNo">102</span> * The default value for this setting is <code>[<js>"."</js>]</code>.<a name="line.102"></a> +<span class="sourceLineNo">103</span> *<a name="line.103"></a> +<span class="sourceLineNo">104</span> * @param searchPaths The new value for this setting.<a name="line.104"></a> +<span class="sourceLineNo">105</span> * @return This object (for method chaining).<a name="line.105"></a> +<span class="sourceLineNo">106</span> */<a name="line.106"></a> +<span class="sourceLineNo">107</span> public ConfigFileBuilder paths(String...searchPaths) {<a name="line.107"></a> +<span class="sourceLineNo">108</span> this.searchPaths = new LinkedList<File>();<a name="line.108"></a> +<span class="sourceLineNo">109</span> for (String p : searchPaths)<a name="line.109"></a> +<span class="sourceLineNo">110</span> this.searchPaths.add(new File(p));<a name="line.110"></a> +<span class="sourceLineNo">111</span> return this;<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> * Make {@link ConfigFile ConfigFiles} read-only.<a name="line.115"></a> +<span class="sourceLineNo">116</span> * <p><a name="line.116"></a> +<span class="sourceLineNo">117</span> * The default value of this setting is <jk>false</jk>.<a name="line.117"></a> +<span class="sourceLineNo">118</span> *<a name="line.118"></a> +<span class="sourceLineNo">119</span> * @return This object (for method chaining).<a name="line.119"></a> +<span class="sourceLineNo">120</span> */<a name="line.120"></a> +<span class="sourceLineNo">121</span> public ConfigFileBuilder readOnly() {<a name="line.121"></a> +<span class="sourceLineNo">122</span> this.readOnly = true;<a name="line.122"></a> +<span class="sourceLineNo">123</span> return this;<a name="line.123"></a> +<span class="sourceLineNo">124</span> }<a name="line.124"></a> +<span class="sourceLineNo">125</span><a name="line.125"></a> +<span class="sourceLineNo">126</span> /**<a name="line.126"></a> +<span class="sourceLineNo">127</span> * Create config files if they cannot be found on the file system.<a name="line.127"></a> +<span class="sourceLineNo">128</span> * <p><a name="line.128"></a> +<span class="sourceLineNo">129</span> * The default value for this setting is <jk>false</jk>.<a name="line.129"></a> +<span class="sourceLineNo">130</span> *<a name="line.130"></a> +<span class="sourceLineNo">131</span> * @return This object (for method chaining).<a name="line.131"></a> +<span class="sourceLineNo">132</span> */<a name="line.132"></a> +<span class="sourceLineNo">133</span> public ConfigFileBuilder createIfNotExists() {<a name="line.133"></a> +<span class="sourceLineNo">134</span> this.createIfNotExists = true;<a name="line.134"></a> +<span class="sourceLineNo">135</span> return this;<a name="line.135"></a> +<span class="sourceLineNo">136</span> }<a name="line.136"></a> +<span class="sourceLineNo">137</span><a name="line.137"></a> +<span class="sourceLineNo">138</span> /**<a name="line.138"></a> +<span class="sourceLineNo">139</span> * Returns the config file with the specified absolute or relative path.<a name="line.139"></a> +<span class="sourceLineNo">140</span> *<a name="line.140"></a> +<span class="sourceLineNo">141</span> * @param path The absolute or relative path of the config file.<a name="line.141"></a> +<span class="sourceLineNo">142</span> * @return The config file.<a name="line.142"></a> +<span class="sourceLineNo">143</span> * @throws IOException If config file could not be parsed.<a name="line.143"></a> +<span class="sourceLineNo">144</span> * @throws FileNotFoundException If config file could not be found.<a name="line.144"></a> +<span class="sourceLineNo">145</span> */<a name="line.145"></a> +<span class="sourceLineNo">146</span> public ConfigFile build(String path) throws IOException {<a name="line.146"></a> +<span class="sourceLineNo">147</span> return new ConfigFileImpl(resolve(path), readOnly, encoder, serializer, parser, charset);<a name="line.147"></a> +<span class="sourceLineNo">148</span> }<a name="line.148"></a> +<span class="sourceLineNo">149</span><a name="line.149"></a> +<span class="sourceLineNo">150</span> /**<a name="line.150"></a> +<span class="sourceLineNo">151</span> * Create a new empty config file not backed by any file.<a name="line.151"></a> +<span class="sourceLineNo">152</span> *<a name="line.152"></a> +<span class="sourceLineNo">153</span> * @return A new config file.<a name="line.153"></a> +<span class="sourceLineNo">154</span> * @throws IOException<a name="line.154"></a> +<span class="sourceLineNo">155</span> */<a name="line.155"></a> +<span class="sourceLineNo">156</span> public ConfigFile build() throws IOException {<a name="line.156"></a> +<span class="sourceLineNo">157</span> return new ConfigFileImpl(null, false, encoder, serializer, parser, charset);<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> /**<a name="line.160"></a> +<span class="sourceLineNo">161</span> * Create a new config file backed by the specified file.<a name="line.161"></a> +<span class="sourceLineNo">162</span> * <p><a name="line.162"></a> +<span class="sourceLineNo">163</span> * This method is provided primarily for testing purposes.<a name="line.163"></a> +<span class="sourceLineNo">164</span> *<a name="line.164"></a> +<span class="sourceLineNo">165</span> * @param f The file to create a config file from.<a name="line.165"></a> +<span class="sourceLineNo">166</span> * @return A new config file.<a name="line.166"></a> +<span class="sourceLineNo">167</span> * @throws IOException<a name="line.167"></a> +<span class="sourceLineNo">168</span> */<a name="line.168"></a> +<span class="sourceLineNo">169</span> public ConfigFile build(File f) throws IOException {<a name="line.169"></a> +<span class="sourceLineNo">170</span> return new ConfigFileImpl(f, false, encoder, serializer, parser, charset);<a name="line.170"></a> +<span class="sourceLineNo">171</span> }<a name="line.171"></a> +<span class="sourceLineNo">172</span><a name="line.172"></a> +<span class="sourceLineNo">173</span> /**<a name="line.173"></a> +<span class="sourceLineNo">174</span> * Create a new config file not backed by a file.<a name="line.174"></a> +<span class="sourceLineNo">175</span> *<a name="line.175"></a> +<span class="sourceLineNo">176</span> * @param r The reader containing an INI-formatted file to initialize the config file from.<a name="line.176"></a> +<span class="sourceLineNo">177</span> * @return A new config file.<a name="line.177"></a> +<span class="sourceLineNo">178</span> * @throws IOException<a name="line.178"></a> +<span class="sourceLineNo">179</span> */<a name="line.179"></a> +<span class="sourceLineNo">180</span> public ConfigFile build(Reader r) throws IOException {<a name="line.180"></a> +<span class="sourceLineNo">181</span> return new ConfigFileImpl(null, false, encoder, serializer, parser, charset).load(r);<a name="line.181"></a> +<span class="sourceLineNo">182</span> }<a name="line.182"></a> +<span class="sourceLineNo">183</span><a name="line.183"></a> +<span class="sourceLineNo">184</span> private File resolve(String path) throws IOException {<a name="line.184"></a> +<span class="sourceLineNo">185</span><a name="line.185"></a> +<span class="sourceLineNo">186</span> // Handle absolute file.<a name="line.186"></a> +<span class="sourceLineNo">187</span> File f = new File(path);<a name="line.187"></a> +<span class="sourceLineNo">188</span> if (f.isAbsolute()) {<a name="line.188"></a> +<span class="sourceLineNo">189</span> if (createIfNotExists)<a name="line.189"></a> +<span class="sourceLineNo">190</span> FileUtils.create(f);<a name="line.190"></a> +<span class="sourceLineNo">191</span> if (f.exists())<a name="line.191"></a> +<span class="sourceLineNo">192</span> return f;<a name="line.192"></a> +<span class="sourceLineNo">193</span> throw new FileNotFoundException("Could not find config file '"+path+"'");<a name="line.193"></a> +<span class="sourceLineNo">194</span> }<a name="line.194"></a> +<span class="sourceLineNo">195</span><a name="line.195"></a> +<span class="sourceLineNo">196</span> if (searchPaths.isEmpty())<a name="line.196"></a> +<span class="sourceLineNo">197</span> throw new FileNotFoundException("No search paths specified in ConfigFileBuilder.");<a name="line.197"></a> +<span class="sourceLineNo">198</span><a name="line.198"></a> +<span class="sourceLineNo">199</span> // Handle paths relative to search paths.<a name="line.199"></a> +<span class="sourceLineNo">200</span> for (File sf : searchPaths) {<a name="line.200"></a> +<span class="sourceLineNo">201</span> f = new File(sf.getAbsolutePath() + "/" + path);<a name="line.201"></a> +<span class="sourceLineNo">202</span> if (f.exists())<a name="line.202"></a> +<span class="sourceLineNo">203</span> return f;<a name="line.203"></a> +<span class="sourceLineNo">204</span> }<a name="line.204"></a> +<span class="sourceLineNo">205</span><a name="line.205"></a> +<span class="sourceLineNo">206</span> if (createIfNotExists) {<a name="line.206"></a> +<span class="sourceLineNo">207</span> f = new File(searchPaths.get(0).getAbsolutePath() + "/" + path);<a name="line.207"></a> +<span class="sourceLineNo">208</span> FileUtils.create(f);<a name="line.208"></a> +<span class="sourceLineNo">209</span> return f;<a name="line.209"></a> +<span class="sourceLineNo">210</span> }<a name="line.210"></a> +<span class="sourceLineNo">211</span><a name="line.211"></a> +<span class="sourceLineNo">212</span> throw new FileNotFoundException("Could not find config file '"+path+"'");<a name="line.212"></a> +<span class="sourceLineNo">213</span> }<a name="line.213"></a> +<span class="sourceLineNo">214</span><a name="line.214"></a> +<span class="sourceLineNo">215</span> /**<a name="line.215"></a> +<span class="sourceLineNo">216</span> * Implements command-line features for working with INI configuration files.<a name="line.216"></a> +<span class="sourceLineNo">217</span> * <p><a name="line.217"></a> +<span class="sourceLineNo">218</span> * Invoke as a normal Java program...<a name="line.218"></a> +<span class="sourceLineNo">219</span> * <p><a name="line.219"></a> +<span class="sourceLineNo">220</span> * <p class='bcode'><a name="line.220"></a> +<span class="sourceLineNo">221</span> * java org.apache.juneau.ini.ConfigFileBuilder [args]<a name="line.221"></a> +<span class="sourceLineNo">222</span> * </p><a name="line.222"></a> +<span class="sourceLineNo">223</span> * <p><a name="line.223"></a> +<span class="sourceLineNo">224</span> * Arguments can be any of the following...<a name="line.224"></a> +<span class="sourceLineNo">225</span> * <ul class='spaced-list'><a name="line.225"></a> +<span class="sourceLineNo">226</span> * <li>No arguments<br><a name="line.226"></a> +<span class="sourceLineNo">227</span> * Prints usage message.<br><a name="line.227"></a> +<span class="sourceLineNo">228</span> * <li><code>createBatchEnvFile -configfile &lt;configFile&gt; -envfile &lt;batchFile&gt; [-verbose]</code><br><a name="line.228"></a> +<span class="sourceLineNo">229</span> * Creates a batch file that will set each config file entry as an environment variable.<br><a name="line.229"></a> +<span class="sourceLineNo">230</span> * Characters in the keys that are not valid as environment variable names (e.g. <js>'/'</js> and <js>'.'</js>)<a name="line.230"></a> +<span class="sourceLineNo">231</span> * will be converted to underscores.<br><a name="line.231"></a> +<span class="sourceLineNo">232</span> * <li><code>createShellEnvFile -configFile &lt;configFile&gt; -envFile &lt;configFile&gt; [-verbose]</code><a name="line.232"></a> +<span class="sourceLineNo">233</span> * Creates a shell script that will set each config file entry as an environment variable.<br><a name="line.233"></a> +<span class="sourceLineNo">234</span> * Characters in the keys that are not valid as environment variable names (e.g. <js>'/'</js> and <js>'.'</js>)<a name="line.234"></a> +<span class="sourceLineNo">235</span> * will be converted to underscores.<br><a name="line.235"></a> +<span class="sourceLineNo">236</span> * <li><code>setVals -configFile &lt;configFile&gt; -vals [var1=val1 [var2=val2...]] [-verbose]</code><a name="line.236"></a> +<span class="sourceLineNo">237</span> * Sets values in config files.<br><a name="line.237"></a> +<span class="sourceLineNo">238</span> * </ul><a name="line.238"></a> +<span class="sourceLineNo">239</span> * <p><a name="line.239"></a> +<span class="sourceLineNo">240</span> * For example, the following command will create the file <code>'MyConfig.bat'</code> from the contents of the file <code>'MyConfig.cfg'</code>.<a name="line.240"></a> +<span class="sourceLineNo">241</span> * <p class='bcode'><a name="line.241"></a> +<span class="sourceLineNo">242</span> * java org.apache.juneau.ini.ConfigFileBuilder createBatchEnvFile -configfile C:\foo\MyConfig.cfg -batchfile C:\foo\MyConfig.bat<a name="line.242"></a> +<span class="sourceLineNo">243</span> * </p><a name="line.243"></a> +<span class="sourceLineNo">244</span> *<a name="line.244"></a> +<span class="sourceLineNo">245</span> * @param args Command-line arguments<a name="line.245"></a> +<span class="sourceLineNo">246</span> */<a name="line.246"></a> +<span class="sourceLineNo">247</span> public static void main(String[] args) {<a name="line.247"></a> +<span class="sourceLineNo">248</span><a name="line.248"></a> +<span class="sourceLineNo">249</span> Args a = new Args(args);<a name="line.249"></a> +<span class="sourceLineNo">250</span> String command = a.getArg(0);<a name="line.250"></a> +<span class="sourceLineNo">251</span> String configFile = a.getArg("configFile");<a name="line.251"></a> +<span class="sourceLineNo">252</span> String envFile = a.getArg("envFile");<a name="line.252"></a> +<span class="sourceLineNo">253</span> List<String> vals = a.getArgs("vals");<a name="line.253"></a> +<span class="sourceLineNo">254</span><a name="line.254"></a> +<span class="sourceLineNo">255</span> if (command == null || ! (command.equals("createBatchEnvFile") || command.equals("createShellEnvFile") || command.equals("setVals")))<a name="line.255"></a> +<span class="sourceLineNo">256</span> printUsageAndExit();<a name="line.256"></a> +<span class="sourceLineNo">257</span> else if (configFile.isEmpty())<a name="line.257"></a> +<span class="sourceLineNo">258</span> printUsageAndExit();<a name="line.258"></a> +<span class="sourceLineNo">259</span> else if (command.equals("setVals") && vals.isEmpty())<a name="line.259"></a> +<span class="sourceLineNo">260</span> printUsageAndExit();<a name="line.260"></a> +<span class="sourceLineNo">261</span> else if ((command.equals("createBatchEnvFile") || command.equals("createShellEnvFile")) && envFile.isEmpty())<a name="line.261"></a> +<span class="sourceLineNo">262</span> printUsageAndExit();<a name="line.262"></a> +<span class="sourceLineNo">263</span> else {<a name="line.263"></a> +<span class="sourceLineNo">264</span> try {<a name="line.264"></a> +<span class="sourceLineNo">265</span> ConfigFile cf = new ConfigFileBuilder().build(configFile);<a name="line.265"></a> +<span class="sourceLineNo">266</span><a name="line.266"></a> +<span class="sourceLineNo">267</span> if (command.equalsIgnoreCase("setVals")) {<a name="line.267"></a> +<span class="sourceLineNo">268</span> for (String val : vals) {<a name="line.268"></a> +<span class="sourceLineNo">269</span> String[] x = val.split("\\=");<a name="line.269"></a> +<span class="sourceLineNo">270</span> if (x.length != 2)<a name="line.270"></a> +<span class="sourceLineNo">271</span> throw new RuntimeException("Invalid format for value: '"+val+"'. Must be in the format 'key=value'");<a name="line.271"></a> +<span class="sourceLineNo">272</span> cf.put(x[0], x[1]);<a name="line.272"></a> +<span class="sourceLineNo">273</span> }<a name="line.273"></a> +<span class="sourceLineNo">274</span> cf.save();<a name="line.274"></a> +<span class="sourceLineNo">275</span> return;<a name="line.275"></a> +<span class="sourceLineNo">276</span><a name="line.276"></a> +<span class="sourceLineNo">277</span> } else if (command.equalsIgnoreCase("createBatchEnvFile")) {<a name="line.277"></a> +<span class="sourceLineNo">278</span> Writer fw = new OutputStreamWriter(new FileOutputStream(envFile), Charset.defaultCharset());<a name="line.278"></a> +<span class="sourceLineNo">279</span> try {<a name="line.279"></a> +<span class="sourceLineNo">280</span> cf.serializeTo(fw, BATCH);<a name="line.280"></a> +<span class="sourceLineNo">281</span> } finally {<a name="line.281"></a> +<span class="sourceLineNo">282</span> fw.close();<a name="line.282"></a> +<span class="sourceLineNo">283</span> }<a name="line.283"></a> +<span class="sourceLineNo">284</span> return;<a name="line.284"></a> +<span class="sourceLineNo">285</span><a name="line.285"></a> +<span class="sourceLineNo">286</span> } else if (command.equalsIgnoreCase("createShellEnvFile")) {<a name="line.286"></a> +<span class="sourceLineNo">287</span> Writer fw = new OutputStreamWriter(new FileOutputStream(envFile), Charset.defaultCharset());<a name="line.287"></a> +<span class="sourceLineNo">288</span> try {<a name="line.288"></a> +<span class="sourceLineNo">289</span> cf.serializeTo(fw, SHELL);<a name="line.289"></a> +<span class="sourceLineNo">290</span> } finally {<a name="line.290"></a> +<span class="sourceLineNo">291</span> fw.close();<a name="line.291"></a> +<span class="sourceLineNo">292</span> }<a name="line.292"></a> +<span class="sourceLineNo">293</span> return;<a name="line.293"></a> +<span class="sourceLineNo">294</span> }<a name="line.294"></a> +<span class="sourceLineNo">295</span><a name="line.295"></a> +<span class="sourceLineNo">296</span> } catch (Exception e) {<a name="line.296"></a> +<span class="sourceLineNo">297</span> e.printStackTrace();<a name="line.297"></a> +<span class="sourceLineNo">298</span> }<a name="line.298"></a> +<span class="sourceLineNo">299</span> }<a name="line.299"></a> +<span class="sourceLineNo">300</span> }<a name="line.300"></a> +<span class="sourceLineNo">301</span><a name="line.301"></a> +<span class="sourceLineNo">302</span> private static void printUsageAndExit() {<a name="line.302"></a> +<span class="sourceLineNo">303</span> System.err.println("---Usage---"); // NOT DEBUG<a name="line.303"></a> +<span class="sourceLineNo">304</span> System.err.println("java -cp juneau.jar org.apache.juneau.ini.ConfigFile createBatchEnvFile -configFile <configFile> -envFile <envFile> [-verbose]"); // NOT DEBUG<a name="line.304"></a> +<span class="sourceLineNo">305</span> System.err.println("java -cp juneau.jar org.apache.juneau.ini.ConfigFile createShellEnvFile -configFile <configFile> -envFile <envFile> [-verbose]"); // NOT DEBUG<a name="line.305"></a> +<span class="sourceLineNo">306</span> System.err.println("java -cp juneau.jar org.apache.juneau.ini.ConfigFile setVals -configFile <configFile> -vals [var1 val1 [var2 val2...]] [-verbose]"); // NOT DEBUG<a name="line.306"></a> +<span class="sourceLineNo">307</span> int rc = Integer.getInteger("exit.2", 2);<a name="line.307"></a> +<span class="sourceLineNo">308</span> if (rc != 0)<a name="line.308"></a> +<span class="sourceLineNo">309</span> System.exit(rc);<a name="line.309"></a> +<span class="sourceLineNo">310</span> }<a name="line.310"></a> +<span class="sourceLineNo">311</span>}<a name="line.311"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/src-html/org/apache/juneau/utils/AList.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/utils/AList.html b/content/site/apidocs/src-html/org/apache/juneau/utils/AList.html new file mode 100644 index 0000000..8c61427 --- /dev/null +++ b/content/site/apidocs/src-html/org/apache/juneau/utils/AList.html @@ -0,0 +1,109 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>// ***************************************************************************************************************************<a name="line.1"></a> +<span class="sourceLineNo">002</span>// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *<a name="line.2"></a> +<span class="sourceLineNo">003</span>// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *<a name="line.3"></a> +<span class="sourceLineNo">004</span>// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *<a name="line.4"></a> +<span class="sourceLineNo">005</span>// * with the License. You may obtain a copy of the License at *<a name="line.5"></a> +<span class="sourceLineNo">006</span>// * *<a name="line.6"></a> +<span class="sourceLineNo">007</span>// * http://www.apache.org/licenses/LICENSE-2.0 *<a name="line.7"></a> +<span class="sourceLineNo">008</span>// * *<a name="line.8"></a> +<span class="sourceLineNo">009</span>// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *<a name="line.9"></a> +<span class="sourceLineNo">010</span>// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *<a name="line.10"></a> +<span class="sourceLineNo">011</span>// * specific language governing permissions and limitations under the License. *<a name="line.11"></a> +<span class="sourceLineNo">012</span>// ***************************************************************************************************************************<a name="line.12"></a> +<span class="sourceLineNo">013</span>package org.apache.juneau.utils;<a name="line.13"></a> +<span class="sourceLineNo">014</span><a name="line.14"></a> +<span class="sourceLineNo">015</span>import java.util.*;<a name="line.15"></a> +<span class="sourceLineNo">016</span><a name="line.16"></a> +<span class="sourceLineNo">017</span>/**<a name="line.17"></a> +<span class="sourceLineNo">018</span> * An extension of {@link LinkedList} with a convenience {@link #append(Object)} method.<a name="line.18"></a> +<span class="sourceLineNo">019</span> * <p><a name="line.19"></a> +<span class="sourceLineNo">020</span> * Primarily used for testing purposes for quickly creating populated lists.<a name="line.20"></a> +<span class="sourceLineNo">021</span> *<a name="line.21"></a> +<span class="sourceLineNo">022</span> * @param <T> The entry type.<a name="line.22"></a> +<span class="sourceLineNo">023</span> */<a name="line.23"></a> +<span class="sourceLineNo">024</span>@SuppressWarnings("serial")<a name="line.24"></a> +<span class="sourceLineNo">025</span>public final class AList<T> extends LinkedList<T> {<a name="line.25"></a> +<span class="sourceLineNo">026</span><a name="line.26"></a> +<span class="sourceLineNo">027</span> /**<a name="line.27"></a> +<span class="sourceLineNo">028</span> * Adds an entry to this list.<a name="line.28"></a> +<span class="sourceLineNo">029</span> *<a name="line.29"></a> +<span class="sourceLineNo">030</span> * @param t The entry to add to this list.<a name="line.30"></a> +<span class="sourceLineNo">031</span> * @return This object (for method chaining).<a name="line.31"></a> +<span class="sourceLineNo">032</span> */<a name="line.32"></a> +<span class="sourceLineNo">033</span> public AList<T> append(T t) {<a name="line.33"></a> +<span class="sourceLineNo">034</span> add(t);<a name="line.34"></a> +<span class="sourceLineNo">035</span> return this;<a name="line.35"></a> +<span class="sourceLineNo">036</span> }<a name="line.36"></a> +<span class="sourceLineNo">037</span>}<a name="line.37"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/src-html/org/apache/juneau/utils/AMap.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/utils/AMap.html b/content/site/apidocs/src-html/org/apache/juneau/utils/AMap.html new file mode 100644 index 0000000..ab4b14e --- /dev/null +++ b/content/site/apidocs/src-html/org/apache/juneau/utils/AMap.html @@ -0,0 +1,111 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>// ***************************************************************************************************************************<a name="line.1"></a> +<span class="sourceLineNo">002</span>// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *<a name="line.2"></a> +<span class="sourceLineNo">003</span>// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *<a name="line.3"></a> +<span class="sourceLineNo">004</span>// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *<a name="line.4"></a> +<span class="sourceLineNo">005</span>// * with the License. You may obtain a copy of the License at *<a name="line.5"></a> +<span class="sourceLineNo">006</span>// * *<a name="line.6"></a> +<span class="sourceLineNo">007</span>// * http://www.apache.org/licenses/LICENSE-2.0 *<a name="line.7"></a> +<span class="sourceLineNo">008</span>// * *<a name="line.8"></a> +<span class="sourceLineNo">009</span>// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *<a name="line.9"></a> +<span class="sourceLineNo">010</span>// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *<a name="line.10"></a> +<span class="sourceLineNo">011</span>// * specific language governing permissions and limitations under the License. *<a name="line.11"></a> +<span class="sourceLineNo">012</span>// ***************************************************************************************************************************<a name="line.12"></a> +<span class="sourceLineNo">013</span>package org.apache.juneau.utils;<a name="line.13"></a> +<span class="sourceLineNo">014</span><a name="line.14"></a> +<span class="sourceLineNo">015</span>import java.util.*;<a name="line.15"></a> +<span class="sourceLineNo">016</span><a name="line.16"></a> +<span class="sourceLineNo">017</span>/**<a name="line.17"></a> +<span class="sourceLineNo">018</span> * An extension of {@link LinkedHashMap} with a convenience {@link #append(Object,Object)} method.<a name="line.18"></a> +<span class="sourceLineNo">019</span> * <p><a name="line.19"></a> +<span class="sourceLineNo">020</span> * Primarily used for testing purposes for quickly creating populated maps.<a name="line.20"></a> +<span class="sourceLineNo">021</span> *<a name="line.21"></a> +<span class="sourceLineNo">022</span> * @param <K> The key type.<a name="line.22"></a> +<span class="sourceLineNo">023</span> * @param <V> The value type.<a name="line.23"></a> +<span class="sourceLineNo">024</span> */<a name="line.24"></a> +<span class="sourceLineNo">025</span>@SuppressWarnings("serial")<a name="line.25"></a> +<span class="sourceLineNo">026</span>public final class AMap<K,V> extends LinkedHashMap<K,V> {<a name="line.26"></a> +<span class="sourceLineNo">027</span><a name="line.27"></a> +<span class="sourceLineNo">028</span> /**<a name="line.28"></a> +<span class="sourceLineNo">029</span> * Adds an entry to this map.<a name="line.29"></a> +<span class="sourceLineNo">030</span> *<a name="line.30"></a> +<span class="sourceLineNo">031</span> * @param k The key.<a name="line.31"></a> +<span class="sourceLineNo">032</span> * @param v The value.<a name="line.32"></a> +<span class="sourceLineNo">033</span> * @return This object (for method chaining).<a name="line.33"></a> +<span class="sourceLineNo">034</span> */<a name="line.34"></a> +<span class="sourceLineNo">035</span> public AMap<K,V> append(K k, V v) {<a name="line.35"></a> +<span class="sourceLineNo">036</span> put(k, v);<a name="line.36"></a> +<span class="sourceLineNo">037</span> return this;<a name="line.37"></a> +<span class="sourceLineNo">038</span> }<a name="line.38"></a> +<span class="sourceLineNo">039</span>}<a name="line.39"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/src-html/org/apache/juneau/utils/ASet.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/utils/ASet.html b/content/site/apidocs/src-html/org/apache/juneau/utils/ASet.html new file mode 100644 index 0000000..606dbd0 --- /dev/null +++ b/content/site/apidocs/src-html/org/apache/juneau/utils/ASet.html @@ -0,0 +1,109 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>// ***************************************************************************************************************************<a name="line.1"></a> +<span class="sourceLineNo">002</span>// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *<a name="line.2"></a> +<span class="sourceLineNo">003</span>// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *<a name="line.3"></a> +<span class="sourceLineNo">004</span>// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *<a name="line.4"></a> +<span class="sourceLineNo">005</span>// * with the License. You may obtain a copy of the License at *<a name="line.5"></a> +<span class="sourceLineNo">006</span>// * *<a name="line.6"></a> +<span class="sourceLineNo">007</span>// * http://www.apache.org/licenses/LICENSE-2.0 *<a name="line.7"></a> +<span class="sourceLineNo">008</span>// * *<a name="line.8"></a> +<span class="sourceLineNo">009</span>// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *<a name="line.9"></a> +<span class="sourceLineNo">010</span>// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *<a name="line.10"></a> +<span class="sourceLineNo">011</span>// * specific language governing permissions and limitations under the License. *<a name="line.11"></a> +<span class="sourceLineNo">012</span>// ***************************************************************************************************************************<a name="line.12"></a> +<span class="sourceLineNo">013</span>package org.apache.juneau.utils;<a name="line.13"></a> +<span class="sourceLineNo">014</span><a name="line.14"></a> +<span class="sourceLineNo">015</span>import java.util.*;<a name="line.15"></a> +<span class="sourceLineNo">016</span><a name="line.16"></a> +<span class="sourceLineNo">017</span>/**<a name="line.17"></a> +<span class="sourceLineNo">018</span> * An extension of {@link LinkedHashSet} with a convenience {@link #append(Object)} method.<a name="line.18"></a> +<span class="sourceLineNo">019</span> * <p><a name="line.19"></a> +<span class="sourceLineNo">020</span> * Primarily used for testing purposes for quickly creating populated sets.<a name="line.20"></a> +<span class="sourceLineNo">021</span> * <a name="line.21"></a> +<span class="sourceLineNo">022</span> * @param <T> The entry type.<a name="line.22"></a> +<span class="sourceLineNo">023</span> */<a name="line.23"></a> +<span class="sourceLineNo">024</span>@SuppressWarnings("serial")<a name="line.24"></a> +<span class="sourceLineNo">025</span>public final class ASet<T> extends LinkedHashSet<T> {<a name="line.25"></a> +<span class="sourceLineNo">026</span><a name="line.26"></a> +<span class="sourceLineNo">027</span> /**<a name="line.27"></a> +<span class="sourceLineNo">028</span> * Adds an entry to this set.<a name="line.28"></a> +<span class="sourceLineNo">029</span> *<a name="line.29"></a> +<span class="sourceLineNo">030</span> * @param t The entry to add to this set.<a name="line.30"></a> +<span class="sourceLineNo">031</span> * @return This object (for method chaining).<a name="line.31"></a> +<span class="sourceLineNo">032</span> */<a name="line.32"></a> +<span class="sourceLineNo">033</span> public ASet<T> append(T t) {<a name="line.33"></a> +<span class="sourceLineNo">034</span> add(t);<a name="line.34"></a> +<span class="sourceLineNo">035</span> return this;<a name="line.35"></a> +<span class="sourceLineNo">036</span> }<a name="line.36"></a> +<span class="sourceLineNo">037</span>}<a name="line.37"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/603b4c69/content/site/apidocs/src-html/org/apache/juneau/utils/StringMessage.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/utils/StringMessage.html b/content/site/apidocs/src-html/org/apache/juneau/utils/StringMessage.html new file mode 100644 index 0000000..14abf7c --- /dev/null +++ b/content/site/apidocs/src-html/org/apache/juneau/utils/StringMessage.html @@ -0,0 +1,148 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>// ***************************************************************************************************************************<a name="line.1"></a> +<span class="sourceLineNo">002</span>// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *<a name="line.2"></a> +<span class="sourceLineNo">003</span>// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *<a name="line.3"></a> +<span class="sourceLineNo">004</span>// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *<a name="line.4"></a> +<span class="sourceLineNo">005</span>// * with the License. You may obtain a copy of the License at *<a name="line.5"></a> +<span class="sourceLineNo">006</span>// * *<a name="line.6"></a> +<span class="sourceLineNo">007</span>// * http://www.apache.org/licenses/LICENSE-2.0 *<a name="line.7"></a> +<span class="sourceLineNo">008</span>// * *<a name="line.8"></a> +<span class="sourceLineNo">009</span>// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *<a name="line.9"></a> +<span class="sourceLineNo">010</span>// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *<a name="line.10"></a> +<span class="sourceLineNo">011</span>// * specific language governing permissions and limitations under the License. *<a name="line.11"></a> +<span class="sourceLineNo">012</span>// ***************************************************************************************************************************<a name="line.12"></a> +<span class="sourceLineNo">013</span>package org.apache.juneau.utils;<a name="line.13"></a> +<span class="sourceLineNo">014</span><a name="line.14"></a> +<span class="sourceLineNo">015</span>import java.io.*;<a name="line.15"></a> +<span class="sourceLineNo">016</span>import java.text.*;<a name="line.16"></a> +<span class="sourceLineNo">017</span><a name="line.17"></a> +<span class="sourceLineNo">018</span>import org.apache.juneau.*;<a name="line.18"></a> +<span class="sourceLineNo">019</span><a name="line.19"></a> +<span class="sourceLineNo">020</span>/**<a name="line.20"></a> +<span class="sourceLineNo">021</span> * An encapsulated MessageFormat-style string and arguments.<a name="line.21"></a> +<span class="sourceLineNo">022</span> * <p><a name="line.22"></a> +<span class="sourceLineNo">023</span> * Useful for delayed serialization of arguments for logging.<a name="line.23"></a> +<span class="sourceLineNo">024</span> * Message string will not be constructed until the <code>toString()</code> method is called.<a name="line.24"></a> +<span class="sourceLineNo">025</span> */<a name="line.25"></a> +<span class="sourceLineNo">026</span>public class StringMessage implements CharSequence, Writable {<a name="line.26"></a> +<span class="sourceLineNo">027</span><a name="line.27"></a> +<span class="sourceLineNo">028</span> private final String pattern;<a name="line.28"></a> +<span class="sourceLineNo">029</span> private final Object[] args;<a name="line.29"></a> +<span class="sourceLineNo">030</span> private String results;<a name="line.30"></a> +<span class="sourceLineNo">031</span><a name="line.31"></a> +<span class="sourceLineNo">032</span> /**<a name="line.32"></a> +<span class="sourceLineNo">033</span> * Constructor.<a name="line.33"></a> +<span class="sourceLineNo">034</span> *<a name="line.34"></a> +<span class="sourceLineNo">035</span> * @param pattern {@link MessageFormat}-style pattern.<a name="line.35"></a> +<span class="sourceLineNo">036</span> * @param args Message arguments.<a name="line.36"></a> +<span class="sourceLineNo">037</span> */<a name="line.37"></a> +<span class="sourceLineNo">038</span> public StringMessage(String pattern, Object...args) {<a name="line.38"></a> +<span class="sourceLineNo">039</span> this.pattern = pattern;<a name="line.39"></a> +<span class="sourceLineNo">040</span> this.args = args;<a name="line.40"></a> +<span class="sourceLineNo">041</span> }<a name="line.41"></a> +<span class="sourceLineNo">042</span><a name="line.42"></a> +<span class="sourceLineNo">043</span> @Override /* Writable */<a name="line.43"></a> +<span class="sourceLineNo">044</span> public void writeTo(Writer w) throws IOException {<a name="line.44"></a> +<span class="sourceLineNo">045</span> w.write(toString());<a name="line.45"></a> +<span class="sourceLineNo">046</span><a name="line.46"></a> +<span class="sourceLineNo">047</span> }<a name="line.47"></a> +<span class="sourceLineNo">048</span><a name="line.48"></a> +<span class="sourceLineNo">049</span> @Override /* Writable */<a name="line.49"></a> +<span class="sourceLineNo">050</span> public MediaType getMediaType() {<a name="line.50"></a> +<span class="sourceLineNo">051</span> // TODO Auto-generated method stub<a name="line.51"></a> +<span class="sourceLineNo">052</span> return null;<a name="line.52"></a> +<span class="sourceLineNo">053</span> }<a name="line.53"></a> +<span class="sourceLineNo">054</span><a name="line.54"></a> +<span class="sourceLineNo">055</span> @Override /* CharSequence */<a name="line.55"></a> +<span class="sourceLineNo">056</span> public char charAt(int index) {<a name="line.56"></a> +<span class="sourceLineNo">057</span> return toString().charAt(index);<a name="line.57"></a> +<span class="sourceLineNo">058</span> }<a name="line.58"></a> +<span class="sourceLineNo">059</span><a name="line.59"></a> +<span class="sourceLineNo">060</span> @Override /* CharSequence */<a name="line.60"></a> +<span class="sourceLineNo">061</span> public int length() {<a name="line.61"></a> +<span class="sourceLineNo">062</span> return toString().length();<a name="line.62"></a> +<span class="sourceLineNo">063</span> }<a name="line.63"></a> +<span class="sourceLineNo">064</span><a name="line.64"></a> +<span class="sourceLineNo">065</span> @Override /* CharSequence */<a name="line.65"></a> +<span class="sourceLineNo">066</span> public CharSequence subSequence(int start, int end) {<a name="line.66"></a> +<span class="sourceLineNo">067</span> return toString().subSequence(start, end);<a name="line.67"></a> +<span class="sourceLineNo">068</span> }<a name="line.68"></a> +<span class="sourceLineNo">069</span><a name="line.69"></a> +<span class="sourceLineNo">070</span> @Override /* Object */<a name="line.70"></a> +<span class="sourceLineNo">071</span> public String toString() {<a name="line.71"></a> +<span class="sourceLineNo">072</span> if (results == null)<a name="line.72"></a> +<span class="sourceLineNo">073</span> results = (args.length == 0 ? pattern : MessageFormat.format(pattern, args));<a name="line.73"></a> +<span class="sourceLineNo">074</span> return results;<a name="line.74"></a> +<span class="sourceLineNo">075</span> }<a name="line.75"></a> +<span class="sourceLineNo">076</span>}<a name="line.76"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html>
