blob: 8d73b125e474af5857f4d12c7b8f1dca92e46274 [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (21) on Thu Oct 05 19:54:57 CEST 2023 -->
<title>UnitFormat (Apache SIS 1.4 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2023-10-05">
<meta name="description" content="declaration: module: org.apache.sis.util, package: org.apache.sis.measure, class: UnitFormat">
<meta name="generator" content="javadoc/ClassWriterImpl">
<meta name="keywords" content="org.apache.sis.measure.UnitFormat class">
<meta name="keywords" content="getLocale()">
<meta name="keywords" content="setLocale()">
<meta name="keywords" content="isLocaleSensitive()">
<meta name="keywords" content="getStyle()">
<meta name="keywords" content="setStyle()">
<meta name="keywords" content="label()">
<meta name="keywords" content="format()">
<meta name="keywords" content="parse()">
<meta name="keywords" content="parseObject()">
<meta name="keywords" content="clone()">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../sis.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-3.6.1.min.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var pathtoroot = "../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span></button>
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="../../../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">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#class">Help</a></li>
</ul>
<ul class="sub-nav-list-small">
<li>
<p>Summary:</p>
<ul>
<li><a href="#nested-class-summary">Nested</a></li>
<li>Field</li>
<li><a href="#constructor-summary">Constr</a></li>
<li><a href="#method-summary">Method</a></li>
</ul>
</li>
<li>
<p>Detail:</p>
<ul>
<li>Field</li>
<li><a href="#constructor-detail">Constr</a></li>
<li><a href="#method-detail">Method</a></li>
</ul>
</li>
</ul>
</div>
<div class="sub-nav">
<div id="navbar-sub-list">
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li><a href="#nested-class-summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor-summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor-detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><a href="../../../../../search.html">SEARCH</a>
<input type="text" id="search-input" disabled placeholder="Search">
<input type="reset" id="reset-button" disabled value="reset">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="module-label-in-type">Module</span>&nbsp;<a href="../../../../module-summary.html">org.apache.sis.util</a></div>
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.sis.measure</a></div>
<h1 title="Class UnitFormat" class="title">Class UnitFormat</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>
<div class="inheritance"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a>
<div class="inheritance">UnitFormat</div>
</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link">Serializable</a></code>, <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Cloneable.html" title="class or interface in java.lang" class="external-link">Cloneable</a></code>, <code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code>, <code><a href="../util/Localized.html" title="interface in org.apache.sis.util">Localized</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public class </span><span class="element-name type-name-label">UnitFormat</span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a>
implements <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">UnitFormat</a>, <a href="../util/Localized.html" title="interface in org.apache.sis.util">Localized</a></span></div>
<div class="block">Parses and formats units of measurement as SI symbols, URI in OGC namespace or other symbols.
This class combines in a single class the API from <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/package-summary.html" class="external-link"><code>java​.text</code></a> and the API from <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/package-summary.html" class="external-link"><code>javax​.measure​.format</code></a>.
In addition to the symbols of the <cite>Système international</cite> (SI), this class is also capable to handle
some symbols found in <cite>Well Known Text</cite> (WKT) definitions or in XML files.
<h2 id="parsing-authority-codes-heading">Parsing authority codes</h2>
If a character sequence given to the <a href="#parse(java.lang.CharSequence)"><code>parse(Char­Sequence)</code></a> method is of the form <code>"EPSG:####"</code>,
<code>"urn:ogc:def:uom:EPSG::####"</code> or <code>"http://www​.opengis​.net/def/uom/EPSG/0/####"</code> (ignoring case
and whitespaces around path separators), then <code>"####"</code> is parsed as an integer and forwarded to the
<a href="Units.html#valueOfEPSG(int)"><code>Units​.value­Of­EPSG(int)</code></a> method.
<h2 id="note-on-netcdf-unit-symbols-heading">Note on netCDF unit symbols</h2>
In netCDF files, values of "unit" attribute are concatenations of an angular unit with an axis direction,
as in <code>"degrees_east"</code> or <code>"degrees_north"</code>. This class ignores those suffixes and unconditionally
returns <a href="Units.html#DEGREE"><code>Units​.DEGREE</code></a> for all axis directions.
<h2 id="multi-threading-heading">Multi-threading</h2>
<code>Unit­Format</code> is generally not thread-safe. If units need to be parsed or formatted in different threads,
each thread should have its own <code>Unit­Format</code> instance.</div>
<dl class="notes">
<dt>Since:</dt>
<dd>0.8</dd>
<dt>See Also:</dt>
<dd>
<ul class="tag-list">
<li><a href="Units.html#valueOf(java.lang.String)"><code>Units​.value­Of(String)</code></a></li>
<li><a href="../../../../../serialized-form.html#org.apache.sis.measure.UnitFormat">Serialized Form</a></li>
</ul>
</dd>
</dl>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<li>
<section class="nested-class-summary" id="nested-class-summary">
<h2>Nested Class Summary</h2>
<div class="caption"><span>Nested Classes</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Class</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>static enum&nbsp;</code></div>
<div class="col-second even-row-color"><code><a href="UnitFormat.Style.html" class="type-name-link" title="enum class in org.apache.sis.measure">Unit­Format​.Style</a></code></div>
<div class="col-last even-row-color">
<div class="block">Identify whether unit formatting uses ASCII symbols, Unicode symbols or full localized names.</div>
</div>
</div>
<div class="inherited-list">
<h2 id="nested-classes-inherited-from-class-java.text.Format">Nested classes/interfaces inherited from class&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></h2>
<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.Field.html" title="class or interface in java.text" class="external-link">Format​.Field</a></code></div>
</section>
</li>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li>
<section class="constructor-summary" id="constructor-summary">
<h2>Constructor Summary</h2>
<div class="caption"><span>Constructors</span></div>
<div class="summary-table two-column-summary">
<div class="table-header col-first">Constructor</div>
<div class="table-header col-last">Description</div>
<div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E(java.util.Locale)" class="member-name-link">Unit­Format</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a>&nbsp;locale)</code></div>
<div class="col-last even-row-color">
<div class="block">Creates a new format for the given locale.</div>
</div>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="UnitFormat.html" title="class in org.apache.sis.measure">Unit­Format</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#clone()" class="member-name-link">clone</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns a clone of this unit format.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/StringBuffer.html" title="class or interface in java.lang" class="external-link">String­Buffer</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#format(java.lang.Object,java.lang.StringBuffer,java.text.FieldPosition)" class="member-name-link">format</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/StringBuffer.html" title="class or interface in java.lang" class="external-link">String­Buffer</a>&nbsp;to­Append­To,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/FieldPosition.html" title="class or interface in java.text" class="external-link">Field­Position</a>&nbsp;pos)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Formats the specified unit in the given buffer.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#format(javax.measure.Unit)" class="member-name-link">format</a><wbr>(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Formats the given unit.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Appendable.html" title="class or interface in java.lang" class="external-link">Appendable</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#format(javax.measure.Unit,java.lang.Appendable)" class="member-name-link">format</a><wbr>(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Appendable.html" title="class or interface in java.lang" class="external-link">Appendable</a>&nbsp;to­Append­To)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Formats the specified unit.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getLocale()" class="member-name-link">get­Locale</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns the locale used by this <code>Unit­Format</code>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="UnitFormat.Style.html" title="enum class in org.apache.sis.measure">Unit­Format​.Style</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getStyle()" class="member-name-link">get­Style</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns whether unit formatting uses ASCII symbols, Unicode symbols or full localized names.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#isLocaleSensitive()" class="member-name-link">is­Locale­Sensitive</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns whether this <code>Unit­Format</code> depends on the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link"><code>Locale</code></a> given at construction time
for performing its tasks.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#label(javax.measure.Unit,java.lang.String)" class="member-name-link">label</a><wbr>(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;label)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Attaches a label to the specified unit.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a><wbr>&lt;?&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#parse(java.lang.CharSequence)" class="member-name-link">parse</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/CharSequence.html" title="class or interface in java.lang" class="external-link">Char­Sequence</a>&nbsp;symbols)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Parses the given text as an instance of <code>Unit</code>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a><wbr>&lt;?&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#parse(java.lang.CharSequence,java.text.ParsePosition)" class="member-name-link">parse</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/CharSequence.html" title="class or interface in java.lang" class="external-link">Char­Sequence</a>&nbsp;symbols,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html" title="class or interface in java.text" class="external-link">Parse­Position</a>&nbsp;position)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Parses a portion of the given text as an instance of <code>Unit</code>.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#parseObject(java.lang.String)" class="member-name-link">parse­Object</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;source)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Parses text from a string to produce a unit.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#parseObject(java.lang.String,java.text.ParsePosition)" class="member-name-link">parse­Object</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;source,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html" title="class or interface in java.text" class="external-link">Parse­Position</a>&nbsp;pos)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Parses text from a string to produce a unit, or returns <code>null</code> if the parsing failed.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setLocale(java.util.Locale)" class="member-name-link">set­Locale</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a>&nbsp;locale)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Sets the locale that this <code>Unit­Format</code> will use for long names.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#setStyle(org.apache.sis.measure.UnitFormat.Style)" class="member-name-link">set­Style</a><wbr>(<a href="UnitFormat.Style.html" title="enum class in org.apache.sis.measure">Unit­Format​.Style</a>&nbsp;style)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Sets whether unit formatting should use ASCII symbols, Unicode symbols or full localized names.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-Format">Methods inherited from class&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#format(java.lang.Object)" title="class or interface in java.text" class="external-link">format</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#formatToCharacterIterator(java.lang.Object)" title="class or interface in java.text" class="external-link">format­To­Character­Iterator</a></code></div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-Object">Methods inherited from class&nbsp;<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">get­Class</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hash­Code</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notify­All</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">to­String</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li>
<section class="constructor-details" id="constructor-detail">
<h2>Constructor Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="&lt;init&gt;(java.util.Locale)">
<h3>UnitFormat</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">UnitFormat</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a>&nbsp;locale)</span></div>
<div class="block">Creates a new format for the given locale.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>locale</code> - the locale to use for parsing and formatting units.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="getLocale()">
<h3>getLocale</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a></span>&nbsp;<span class="element-name">getLocale</span>()</div>
<div class="block">Returns the locale used by this <code>Unit­Format</code>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="../util/Localized.html#getLocale()">get­Locale</a></code>&nbsp;in interface&nbsp;<code><a href="../util/Localized.html" title="interface in org.apache.sis.util">Localized</a></code></dd>
<dt>Returns:</dt>
<dd>the locale of this <code>Unit­Format</code>.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="setLocale(java.util.Locale)">
<h3>setLocale</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setLocale</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link">Locale</a>&nbsp;locale)</span></div>
<div class="block">Sets the locale that this <code>Unit­Format</code> will use for long names.
For example, a call to <code>set­Locale(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html#US" title="class or interface in java.util" class="external-link">Locale​.US</a>)</code>
instructs this formatter to use the “meter” spelling instead of “metre”.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>locale</code> - the new locale for this <code>Unit­Format</code>.</dd>
<dt>See Also:</dt>
<dd>
<ul class="tag-list-long">
<li><a href="UnitServices.html#getUnitFormat(java.lang.String)"><code>Unit­Services​.get­Unit­Format(String)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="isLocaleSensitive()">
<h3>isLocaleSensitive</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">isLocaleSensitive</span>()</div>
<div class="block">Returns whether this <code>Unit­Format</code> depends on the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Locale.html" title="class or interface in java.util" class="external-link"><code>Locale</code></a> given at construction time
for performing its tasks. This method returns <code>true</code> if formatting long names (e.g. “metre”
or “meter”} and <code>false</code> if formatting only the unit symbol (e.g. “m”).</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#isLocaleSensitive()" title="class or interface in javax.measure.format" class="external-link">is­Locale­Sensitive</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Returns:</dt>
<dd><code>true</code> if formatting depends on the locale.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getStyle()">
<h3>getStyle</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="UnitFormat.Style.html" title="enum class in org.apache.sis.measure">UnitFormat.Style</a></span>&nbsp;<span class="element-name">getStyle</span>()</div>
<div class="block">Returns whether unit formatting uses ASCII symbols, Unicode symbols or full localized names.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>the style of units formatted by this <code>Unit­Format</code> instance.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="setStyle(org.apache.sis.measure.UnitFormat.Style)">
<h3>setStyle</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setStyle</span><wbr><span class="parameters">(<a href="UnitFormat.Style.html" title="enum class in org.apache.sis.measure">UnitFormat.Style</a>&nbsp;style)</span></div>
<div class="block">Sets whether unit formatting should use ASCII symbols, Unicode symbols or full localized names.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>style</code> - the desired style of units.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="label(javax.measure.Unit,java.lang.String)">
<h3>label</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">label</span><wbr><span class="parameters">(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;label)</span></div>
<div class="block">Attaches a label to the specified unit. A <cite>label</cite> can be a substitute to either the
<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html#getSymbol()" title="class or interface in javax.measure" class="external-link">unit symbol</a> or the <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html#getName()" title="class or interface in javax.measure" class="external-link"><code>unit name</code></a>,
depending on the <a href="#getStyle()">format style</a>.
If the specified label is already associated to another unit, then the previous association is discarded.
<h4 id="restriction-on-character-set-heading">Restriction on character set</h4>
Current implementation accepts only <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Character.html#isLetter(int)" title="class or interface in java.lang" class="external-link">letters</a>,
<a href="../util/Characters.html#isSubScript(int)">subscripts</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Character.html#isSpaceChar(int)" title="class or interface in java.lang" class="external-link">spaces</a>
(including non-breaking spaces but not CR/LF characters),
the degree sign (°) and a few other characters like underscore.
The set of legal characters may be expanded in future Apache SIS versions,
but the following restrictions are likely to remain:
<ul>
<li>The following characters are reserved since they have special meaning in UCUM format, in URI
or in Apache SIS parser: <blockquote>" # ( ) * + - . / : = ? [ ] { } ^ ⋅ ∕</blockquote></li>
<li>The symbol cannot begin or end with digits, since such digits would be confused with unit power.</li>
</ul></div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#label(javax.measure.Unit,java.lang.String)" title="class or interface in javax.measure.format" class="external-link">label</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>unit</code> - the unit being labeled.</dd>
<dd><code>label</code> - the new label for the given unit.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">Illegal­Argument­Exception</a></code> - if the given label is not a valid unit name.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="format(javax.measure.Unit,java.lang.Appendable)">
<h3>format</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Appendable.html" title="class or interface in java.lang" class="external-link">Appendable</a></span>&nbsp;<span class="element-name">format</span><wbr><span class="parameters">(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Appendable.html" title="class or interface in java.lang" class="external-link">Appendable</a>&nbsp;toAppendTo)</span>
throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/IOException.html" title="class or interface in java.io" class="external-link">IOException</a></span></div>
<div class="block">Formats the specified unit.
This method performs the first of the following actions that can be done.
<ol>
<li>If a <a href="#label(javax.measure.Unit,java.lang.String)">label has been specified</a> for the given unit,
then that label is appended unconditionally.</li>
<li>Otherwise if the formatting style is <a href="UnitFormat.Style.html#NAME"><code>Unit­Format​.Style​.NAME</code></a> and the <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html#getName()" title="class or interface in javax.measure" class="external-link"><code>Unit​.get­Name()</code></a> method
returns a non-null value, then that value is appended. <code>Unit</code> instances implemented by
Apache SIS are handled in a special way for localizing the name according the
<a href="#setLocale(java.util.Locale)">locale specified to this format</a>.</li>
<li>Otherwise if the <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html#getSymbol()" title="class or interface in javax.measure" class="external-link"><code>Unit​.get­Symbol()</code></a> method returns a non-null value,
then that value is appended.</li>
<li>Otherwise a default symbol is created from the entries returned by <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html#getBaseUnits()" title="class or interface in javax.measure" class="external-link"><code>Unit​.get­Base­Units()</code></a>.</li>
</ol></div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#format(javax.measure.Unit,java.lang.Appendable)" title="class or interface in javax.measure.format" class="external-link">format</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>unit</code> - the unit to format.</dd>
<dd><code>to­Append­To</code> - where to format the unit.</dd>
<dt>Returns:</dt>
<dd>the given <code>to­Append­To</code> argument, for method calls chaining.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/IOException.html" title="class or interface in java.io" class="external-link">IOException</a></code> - if an error occurred while writing to the destination.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="format(java.lang.Object,java.lang.StringBuffer,java.text.FieldPosition)">
<h3>format</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/StringBuffer.html" title="class or interface in java.lang" class="external-link">StringBuffer</a></span>&nbsp;<span class="element-name">format</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&nbsp;unit,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/StringBuffer.html" title="class or interface in java.lang" class="external-link">StringBuffer</a>&nbsp;toAppendTo,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/FieldPosition.html" title="class or interface in java.text" class="external-link">FieldPosition</a>&nbsp;pos)</span></div>
<div class="block">Formats the specified unit in the given buffer.
This method delegates to <a href="#format(javax.measure.Unit,java.lang.Appendable)"><code>format(Unit, Appendable)</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#format(java.lang.Object,java.lang.StringBuffer,java.text.FieldPosition)" title="class or interface in java.text" class="external-link">format</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>unit</code> - the unit to format.</dd>
<dd><code>to­Append­To</code> - where to format the unit.</dd>
<dd><code>pos</code> - where to store the position of a formatted field, or <code>null</code> if none.</dd>
<dt>Returns:</dt>
<dd>the given <code>to­Append­To</code> argument, for method calls chaining.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="format(javax.measure.Unit)">
<h3>format</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">format</span><wbr><span class="parameters">(<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;&nbsp;unit)</span></div>
<div class="block">Formats the given unit.
This method delegates to <a href="#format(javax.measure.Unit,java.lang.Appendable)"><code>format(Unit, Appendable)</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#format(javax.measure.Unit)" title="class or interface in javax.measure.format" class="external-link">format</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>unit</code> - the unit to format.</dd>
<dt>Returns:</dt>
<dd>the formatted unit.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="parse(java.lang.CharSequence)">
<h3>parse</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;</span>&nbsp;<span class="element-name">parse</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/CharSequence.html" title="class or interface in java.lang" class="external-link">CharSequence</a>&nbsp;symbols)</span>
throws <span class="exceptions"><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link">MeasurementParseException</a></span></div>
<div class="block">Parses the given text as an instance of <code>Unit</code>.
If the parse completes without reading the entire length of the text, an exception is thrown.
<p>The parsing is lenient: symbols can be products or quotients of units like “m∕s”,
words like “meters per second”, or authority codes like <code>"urn:ogc:def:uom:EPSG::1026"</code>.
The product operator can be either <code>'.'</code> (ASCII) or <code>'⋅'</code> (Unicode) character.
Exponent after symbol can be decimal digits as in “m2” or a superscript as in “m²”.</p>
<p>This method differs from <a href="#parse(java.lang.CharSequence,java.text.ParsePosition)"><code>parse(Char­Sequence, Parse­Position)</code></a> in the treatment of white spaces:
that method with a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html" title="class or interface in java.text" class="external-link"><code>Parse­Position</code></a> argument stops parsing at the first white space,
while this <code>parse(…)</code> method treats white spaces as multiplications.
The reason for this difference is that white space is normally not a valid multiplication symbol;
it could be followed by a text which is not part of the unit symbol.
But in the case of this <code>parse(Char­Sequence)</code> method, the whole <code>Char­Sequence</code> shall be a unit symbol.
In such case, white spaces are less ambiguous.</p>
<p>The default implementation delegates to
<code><a href="#parse(java.lang.CharSequence,java.text.ParsePosition)">parse</a>(symbols, new Parse­Position(0))</code>
and verifies that all non-white characters have been parsed.
Units separated by spaces are multiplied; for example "kg m**-2" is parsed as kg/m².</p></div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#parse(java.lang.CharSequence)" title="class or interface in javax.measure.format" class="external-link">parse</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>symbols</code> - the unit symbols or URI to parse.</dd>
<dt>Returns:</dt>
<dd>the unit parsed from the specified symbols.</dd>
<dt>Throws:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link">Measurement­Parse­Exception</a></code> - if a problem occurred while parsing the given symbols.</dd>
<dt>See Also:</dt>
<dd>
<ul class="tag-list">
<li><a href="Units.html#valueOf(java.lang.String)"><code>Units​.value­Of(String)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="parse(java.lang.CharSequence,java.text.ParsePosition)">
<h3>parse</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Unit.html" title="class or interface in javax.measure" class="external-link">Unit</a>&lt;?&gt;</span>&nbsp;<span class="element-name">parse</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/CharSequence.html" title="class or interface in java.lang" class="external-link">CharSequence</a>&nbsp;symbols,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html" title="class or interface in java.text" class="external-link">ParsePosition</a>&nbsp;position)</span>
throws <span class="exceptions"><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link">MeasurementParseException</a></span></div>
<div class="block">Parses a portion of the given text as an instance of <code>Unit</code>.
Parsing begins at the index given by <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html#getIndex()" title="class or interface in java.text" class="external-link"><code>Parse­Position​.get­Index()</code></a>.
After parsing, the above-cited index is updated to the first unparsed character.
<p>The parsing is lenient: symbols can be products or quotients of units like “m∕s”,
words like “meters per second”, or authority codes like <code>"urn:ogc:def:uom:EPSG::1026"</code>.
The product operator can be either <code>'.'</code> (ASCII) or <code>'⋅'</code> (Unicode) character.
Exponent after symbol can be decimal digits as in “m2” or a superscript as in “m²”.</p>
<p>Note that contrarily to <a href="#parseObject(java.lang.String,java.text.ParsePosition)"><code>parse­Object(String, Parse­Position)</code></a>, this method never return <code>null</code>.
If an error occurs at parsing time, an unchecked <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link"><code>Measurement­Parse­Exception</code></a> is thrown.</p></div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html#parse(java.lang.CharSequence,java.text.ParsePosition)" title="class or interface in javax.measure.format" class="external-link">parse</a></code>&nbsp;in interface&nbsp;<code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/UnitFormat.html" title="class or interface in javax.measure.format" class="external-link">Unit­Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>symbols</code> - the unit symbols to parse.</dd>
<dd><code>position</code> - on input, index of the first character to parse.
On output, index after the last parsed character.</dd>
<dt>Returns:</dt>
<dd>the unit parsed from the specified symbols.</dd>
<dt>Throws:</dt>
<dd><code><a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link">Measurement­Parse­Exception</a></code> - if a problem occurred while parsing the given symbols.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="parseObject(java.lang.String)">
<h3>parseObject</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span>&nbsp;<span class="element-name">parseObject</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;source)</span>
throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParseException.html" title="class or interface in java.text" class="external-link">ParseException</a></span></div>
<div class="block">Parses text from a string to produce a unit. The default implementation delegates
to <a href="#parse(java.lang.CharSequence)"><code>parse(Char­Sequence)</code></a> and wraps the <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link"><code>Measurement­Parse­Exception</code></a>
into a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParseException.html" title="class or interface in java.text" class="external-link"><code>Parse­Exception</code></a> for compatibility with <code>java​.text</code> API.</div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#parseObject(java.lang.String)" title="class or interface in java.text" class="external-link">parse­Object</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>source</code> - the text, part of which should be parsed.</dd>
<dt>Returns:</dt>
<dd>a unit parsed from the string.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParseException.html" title="class or interface in java.text" class="external-link">Parse­Exception</a></code> - if the given string cannot be fully parsed.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="parseObject(java.lang.String,java.text.ParsePosition)">
<h3>parseObject</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span>&nbsp;<span class="element-name">parseObject</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;source,
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/ParsePosition.html" title="class or interface in java.text" class="external-link">ParsePosition</a>&nbsp;pos)</span></div>
<div class="block">Parses text from a string to produce a unit, or returns <code>null</code> if the parsing failed.
The default implementation delegates to <a href="#parse(java.lang.CharSequence,java.text.ParsePosition)"><code>parse(Char­Sequence, Parse­Position)</code></a> and catches
the <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/format/MeasurementParseException.html" title="class or interface in javax.measure.format" class="external-link"><code>Measurement­Parse­Exception</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#parseObject(java.lang.String,java.text.ParsePosition)" title="class or interface in java.text" class="external-link">parse­Object</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></code></dd>
<dt>Parameters:</dt>
<dd><code>source</code> - the text, part of which should be parsed.</dd>
<dd><code>pos</code> - index and error index information as described above.</dd>
<dt>Returns:</dt>
<dd>a unit parsed from the string, or <code>null</code> in case of error.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="clone()">
<h3>clone</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="UnitFormat.html" title="class in org.apache.sis.measure">UnitFormat</a></span>&nbsp;<span class="element-name">clone</span>()</div>
<div class="block">Returns a clone of this unit format. The new unit format will be initialized to the same
<a href="#getLocale()">locale</a> and <a href="#label(javax.measure.Unit,java.lang.String)">labels</a> than this format.</div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html#clone()" title="class or interface in java.text" class="external-link">clone</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/Format.html" title="class or interface in java.text" class="external-link">Format</a></code></dd>
<dt>Returns:</dt>
<dd>a clone of this unit format.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
</div>
</div>
</body>
</html>