001/*
002 * ============================================================================
003 * Copyright © 2002-2025 by Thomas Thrien.
004 * All Rights Reserved.
005 * ============================================================================
006 * Licensed to the public under the agreements of the GNU Lesser General Public
007 * License, version 3.0 (the "License"). You may obtain a copy of the License at
008 *
009 *      http://www.gnu.org/licenses/lgpl.html
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014 * License for the specific language governing permissions and limitations
015 * under the License.
016 */
017
018package org.tquadrat.foundation.lang;
019
020import static java.lang.System.lineSeparator;
021import static org.apiguardian.api.API.Status.DEPRECATED;
022import static org.apiguardian.api.API.Status.STABLE;
023
024import java.math.BigDecimal;
025import java.nio.charset.Charset;
026import java.nio.charset.StandardCharsets;
027import java.text.DecimalFormat;
028import java.text.NumberFormat;
029import java.time.ZoneId;
030import java.time.ZoneOffset;
031import java.util.PropertyResourceBundle;
032import java.util.TimeZone;
033import java.util.function.Predicate;
034
035import org.apiguardian.api.API;
036import org.tquadrat.foundation.annotation.ClassVersion;
037import org.tquadrat.foundation.annotation.UtilityClass;
038import org.tquadrat.foundation.exception.PrivateConstructorForStaticClassCalledError;
039
040/**
041 *  <p>{@summary This class provides a bunch of commonly used constants.}</p>
042 *  <p>The constants are arranged into several categories.</p>
043 *  <ul>
044 *      <li>Physical constants like gravity and speed of light.</li>
045 *      <li>XML constants, like often used names for entities and
046 *      attributes.</li>
047 *      <li>Miscellaneous constants like the empty string or the null
048 *      char.</li>
049 *  </ul>
050 *
051 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
052 *  @version $Id: CommonConstants.java 1151 2025-10-01 21:32:15Z tquadrat $
053 *  @since 0.0.5
054 *
055 *  @UMLGraph.link
056 */
057@SuppressWarnings( {"UnnecessaryUnicodeEscape"} )
058@ClassVersion( sourceVersion = "$Id: CommonConstants.java 1151 2025-10-01 21:32:15Z tquadrat $" )
059@UtilityClass
060public final class CommonConstants
061{
062        /*-----------*\
063    ====** Constants **========================================================
064        \*-----------*/
065    //---* Some character constants *------------------------------------------
066    /**
067     *  The horizontal ellipsis: &hellip;
068     *  (&amp;hellip;/&amp;#8230;/&amp;#x2026;/\u2026).
069     */
070    @API( status = STABLE, since = "0.0.5" )
071    public static final char CHAR_ELLIPSIS = '\u2026';
072
073    /**
074     *  The hyphen character (&amp;#8208;/&amp;#x2010;/\u2010/HYPHEN).<br>
075     *  <br>This is different from the character '&#x002D;' (HYPHEN-MINUS),
076     *  although it looks similar. This character can be used as a replacement
077     *  for the HYPHEN-MINUS in contexts where HYPHEN-MINUS has a special
078     *  meaning.
079     */
080    /*
081     * For some reason, JavaDoc refuses to accept both &#8208; and &#x2010;
082     * as valid entities.
083     */
084    @API( status = STABLE, since = "0.0.5" )
085    public static final char CHAR_HYPHEN = '\u2010';
086
087    /**
088     *  The non-breaking space character (&amp;#x00A0;/\u00A0).
089     */
090    @API( status = STABLE, since = "0.0.5" )
091    public static final char CHAR_NBSP = '\u00A0';
092
093    /**
094     *  The  small non-breaking space character (&amp;#x202F;/\u202F).
095     */
096    @API( status = STABLE, since = "0.0.5" )
097    public static final char CHAR_NNBSP = '\u202F';
098
099    /**
100     *  The zero-width non-breaking space character; in fact, the 'word joiner'
101     *  character that should be used instead of the original character.
102     */
103    @API( status = STABLE, since = "0.0.5" )
104    public static final char CHAR_ZWNBSP = '\u2060';
105
106    //---* Empty Array Constants *---------------------------------------------
107    /**
108     *  An empty array of
109     *  {@link Object}
110     *  objects.
111     */
112    @API( status = STABLE, since = "0.0.5" )
113    public static final Object [] EMPTY_Object_ARRAY = new Object [0];
114
115    /**
116     *  An empty array of
117     *  {@link String}
118     *  instances.
119     */
120    @API( status = STABLE, since = "0.0.5" )
121    public static final String [] EMPTY_String_ARRAY = new String [0];
122
123    //---* Numerical constants that are not in Math *--------------------------
124    /**
125     *  The Gravity constant:
126     *  6.672E-11&nbsp;(N&nbsp;*&nbsp;m<sup>2</sup>)/(kg<sup>2</sup>). An
127     *  alternative unit for the constant is
128     *  (m<sup>3</sup>)/(kg&nbsp;*&nbsp;s<sup>2</sup>).
129     */
130    @API( status = STABLE, since = "0.0.5" )
131    public static final BigDecimal GRAVITY_CONSTANT = new BigDecimal( "6.672E-11" );
132
133    /**
134     *  The speed of light in km per second = 299792.458&nbsp;km/s.
135     */
136    @API( status = STABLE, since = "0.0.5" )
137    public static final BigDecimal SPEED_OF_LIGHT =  new BigDecimal( "299792.458" );
138
139    /**
140     *  The value for 1 G: 9.80665&nbsp;m/(s<sup>2</sup>)
141     */
142    @API( status = STABLE, since = "0.0.5" )
143    public static final BigDecimal STANDARD_G =  new BigDecimal( "9.80665" );
144
145    /**
146     *  <p>{@summary The time between 1582-10-15T00:00 (the start of the
147     *  Gregorian calendar) and 1970-01-01T00:00 (the beginning of the "Epoch")
148     *  in seconds: {@value}.}</p>
149     *  <p>This constant is used for example to determine the number of
150     *  nanoseconds since the beginning of the Gregorian calendar, and that is
151     *  used to create UUIDs based on time and location.</p>
152     *
153     *  @see java.util.UUID
154     */
155    @API( status = STABLE, since = "0.0.5" )
156    public static final long TIME_DELTA_BEGINGREGORIAN2BEGINEPOCH = 12219292800L;
157
158    /**
159     *  The length of a (tropical) year in days, according to SI:
160     *  365.242190517&nbsp;d.
161     */
162    @API( status = STABLE, since = "0.0.5" )
163    public static final BigDecimal TROPICAL_YEAR =  new BigDecimal( "365.242190517" );
164
165    //---* Names of System Environment variables *-----------------------------
166    /*
167     * Most of these depend on the underlying operating environment, but some
168     * are commonly used on all operating systems.
169     */
170    /**
171     *  The Java installation directory: {@value}.
172     *
173     *  @see #PROPERTY_JAVA_HOME
174     */
175    @API( status = STABLE, since = "0.0.5" )
176    public static final String ENV_JAVA_HOME = "JAVA_HOME";
177
178    //---* Names of System Properties *----------------------------------------
179    /**
180     *  <p>{@summary The system property for the application id as used by the
181     *  logging sub-system: {@value}.}</p>
182     *  <p>For details on this refer to the project {@code logging}.</p>
183     */
184    @API( status = STABLE, since = "0.0.5" )
185    public static final String PROPERTY_APPLICATIONID = "org.tquadrat.logging.applicationId";
186
187    /**
188     *  The vested system property for the current class path: {@value}.
189     */
190    @API( status = STABLE, since = "0.0.5" )
191    public static final String PROPERTY_CLASSPATH = "java.class.path";
192
193    /**
194     *  The vested system property for the architecture of the current CPU:
195     *  {@value}.
196     */
197    @API( status = STABLE, since = "0.0.5" )
198    public static final String PROPERTY_CPUARCHITECTURE = "os.arch";
199
200    /**
201     *  The vested system property for the file encoding used by the JVM:
202     *  {@value}.
203     */
204    @API( status = STABLE, since = "0.0.6" )
205    public static final String PROPERTY_FILE_ENCODING = "file.encoding";
206
207    /**
208     *  <p>{@summary The system property providing the flag that indicates
209     *  whether the program is running in a headless mode, meaning that is
210     *  does not have any kind of a graphical user interface: {@value}.}</p>
211     *  <p>Instead of checking the property directly, a call to
212     *  {@code java.awt.GraphicsEnvironment#isHeadless()} will return the same
213     *  result, but it would require to add the module {@code java.desktop} to
214     *  the dependencies of the current module.</p>
215     *  <p>JavaFX does not have a headless mode as such (although there are
216     *  several solutions for headless testing of JavaFX applications), but
217     *  this flag can still be used to decide whether a JavaFX can run or not:
218     *  basically, AWT, Swing and JavaFX need the same resources, a keyboard, a
219     *  mouse and a graphical display.</p>
220     *
221     *  @see <a href="https://www.oracle.com/technical-resources/articles/javase/headless.html">Using Headless Mode in the Java SE Platform</a>
222     */
223    @API( status = STABLE, since = "0.1.0" )
224    public static final String PROPERTY_HEADLESS = "java.awt.headless";
225
226    /**
227     *  The system property that is used to enable the debug mode: {@value}.
228     */
229    @API( status = STABLE, since = "0.0.5" )
230    public static final String PROPERTY_IS_DEBUG = "isDebug";
231
232    /**
233     *  The system property that is used to enable the test mode: {@value}.
234     */
235    @API( status = STABLE, since = "0.0.5" )
236    public static final String PROPERTY_IS_TEST = "isTest";
237
238    /**
239     *  The vested system property for the Java installation directory:
240     *  {@value}.
241     */
242    @API( status = STABLE, since = "0.0.5" )
243    public static final String PROPERTY_JAVA_HOME = "java.home";
244
245    /**
246     *  The system property for the name of the Java runtime: {@value}.
247     */
248    @API( status = STABLE, since = "0.0.5" )
249    public static final String PROPERTY_JAVA_RUNTIME = "java.runtime.name";
250
251    /**
252     *  The vested system property for the Java vendor: {@value}.
253     */
254    @API( status = STABLE, since = "0.0.5" )
255    public static final String PROPERTY_JAVA_VENDOR = "java.vendor";
256
257    /**
258     *  The vested system property for the homepage URL of the Java vendor:
259     *  {@value}.
260     */
261    @API( status = STABLE, since = "0.0.5" )
262    public static final String PROPERTY_JAVA_VENDOR_URL = "java.vendor.url";
263
264    /**
265     *  The vested system property for the Java version: {@value}.
266     */
267    @API( status = STABLE, since = "0.0.5" )
268    public static final String PROPERTY_JAVA_VERSION = "java.version";
269
270    /**
271     *  The vested system property for the name of the current JVM: {@value}.
272     */
273    @API( status = STABLE, since = "0.0.5" )
274    public static final String PROPERTY_JVM_NAME = "java.vm.name";
275
276    /**
277     *  The vested system property for the name of the vendor for the current
278     *  JVM: {@value}.
279     */
280    @API( status = STABLE, since = "0.0.5" )
281    public static final String PROPERTY_JVM_VENDOR = "java.vm.vendor";
282
283    /**
284     *  The vested system property for the version of the current JVM:
285     *  {@value}.
286     */
287    @API( status = STABLE, since = "0.0.5" )
288    public static final String PROPERTY_JVM_VERSION = "java.vm.version";
289
290    /**
291     *  The vested system property for the line separator: {@value}.
292     */
293    @API( status = STABLE, since = "0.0.5" )
294    public static final String PROPERTY_LINE_SEPARATOR = "line.separator";
295
296    /**
297     *  The optional system property for the name of the class that provides
298     *  the configuration the JDK logger: {@value}.
299     */
300    @API( status = STABLE, since = "0.0.5" )
301    public static final String PROPERTY_LOGGING_CONFIG_CLASS = "java.util.logging.config.class";
302
303    /**
304     *  The optional system property for the name of the configuration file for
305     *  the JDK logger: {@value}.
306     */
307    @API( status = STABLE, since = "0.0.5" )
308    public static final String PROPERTY_LOGGING_CONFIG_FILE = "java.util.logging.config.file";
309
310    /**
311     *  <p>{@summary The optional system property for enabling java mail
312     *  session debug: {@value}.}</p>
313     *  <p>This flag will not be recognised automatically. Refer to the
314     *  documentation of {@code javax.mail.Session}.
315     */
316    @API( status = STABLE, since = "0.1.0" )
317    public static final String PROPERTY_MAIL_SESSION_DEBUG = "javax.mail.Session.debug";
318
319    /**
320     *  The (vested [?]) system property for the current module path: {@value}.
321     */
322    @API( status = STABLE, since = "0.0.5" )
323    public static final String PROPERTY_MODULEPATH = "jdk.module.path";
324
325    /**
326     *  The system property for the name of the packages with URL protocol
327     *  handlers: {@value}.
328     */
329    @API( status = STABLE, since = "0.0.5" )
330    public static final String PROPERTY_NET_PROTOCOL_PKGS = "java.protocol.handler.pkgs";
331
332    /**
333     *  The vested system property for the name of the current operating
334     *  system: {@value}.
335     */
336    @API( status = STABLE, since = "0.0.5" )
337    public static final String PROPERTY_OSNAME = "os.name";
338
339    /**
340     *  The vested system property for the version of the current operating
341     *  system: {@value}.
342     */
343    @API( status = STABLE, since = "0.0.5" )
344    public static final String PROPERTY_OSVERSION = "os.version";
345
346    /**
347     *  The system property for the location of the system preferences files on
348     *  a UNIX/Linux system: {@value}.<br>
349     *  <br>If not set, the location is {@code /etc/}, resulting to
350     *  {@code /etc/.java/.systemPrefs}.<br>
351     *  <br>If the default location is used, the respective folder has to be
352     *  created by a user with {@code root} permissions; the files in there
353     *  should have the rights 544, while the folder and its sub-folders should
354     *  have 755.
355     */
356    @API( status = STABLE, since = "0.0.6" )
357    public static final String PROPERTY_PREFS_ROOT_SYSTEM = "java.util.prefs.systemRoot";
358
359    /**
360     *  The system property for the location of the user preferences files on
361     *  a UNIX/Linux system: {@value}.<br>
362     *  <br>If not set, the location is {@code ~/}, resulting to
363     *  {@code ~/.java/.userPrefs/}.
364     */
365    @API( status = STABLE, since = "0.0.6" )
366    public static final String PROPERTY_PREFS_ROOT_USER = "java.util.prefs.userRoot";
367
368    /**
369     *  The system property for the synchronisation interval of the preferences
370     *  on a UNIX/Linux system, in seconds: {@value}.<br>
371     *  <br>If not set, the interval is 30 seconds. The minimum value is one
372     *  second.
373     */
374    @API( status = STABLE, since = "0.0.6" )
375    public static final String PROPERTY_PREFS_SYNC = "java.util.prefs.syncInterval";
376
377    /**
378     *  <p>{@summary The system property that is used to force the encoding for a
379     *  {@link PropertyResourceBundle}:
380     *  {@value}.} Valid values are &quot;{@code UTF-8}&quot; and
381     *  &quot;{@code ISO-8859-1}&quot;.
382     */
383    @API( status = STABLE, since = "0.1.0" )
384    public static final String PROPERTY_RESOURCEBUNDLE_ENCODING = "java.util.PropertyResourceBundle.encoding";
385
386    /**
387     *  The system property for the class name of the SAX XML parser factory:
388     *  {@value}.<br>
389     */
390    @API( status = STABLE, since = "0.0.7" )
391    public static final String PROPERTY_SAX_PARSER_FACTORY = "javax.xml.parsers.SAXParserFactory";
392
393    /**
394     *  The system property for the name of the file with the SSL key store:
395     *  {@value}.
396     */
397    @API( status = STABLE, since = "0.0.7" )
398    public static final String PROPERTY_SSL_KEYSTORE = "javax.net.ssl.keyStore";
399
400    /**
401     *  The system property for the password for the SSL key store: {@value}.
402     *
403     *  @see #PROPERTY_SSL_KEYSTORE
404     */
405    @API( status = STABLE, since = "0.0.7" )
406    public static final String PROPERTY_SSL_KEYSTORE_PASSWORD = "javax.net.ssl.keyStorePassword";
407
408    /**
409     *  The vested system property for the name of the {@code temp} folder that
410     *  is used by the current user: {@value}.
411     */
412    @API( status = STABLE, since = "0.0.5" )
413    public static final String PROPERTY_TEMPFOLDER = "java.io.tmpdir";
414
415    /**
416     *  The system property for the country code setting for the current user:
417     *  {@value}.
418     */
419    @API( status = STABLE, since = "0.0.5" )
420    public static final String PROPERTY_USER_COUNTRY = "user.country";
421
422    /**
423     *  The vested system property for the name of the current working
424     *  directory of the current user: {@value}.
425     */
426    @API( status = STABLE, since = "0.0.5" )
427    public static final String PROPERTY_USER_DIR = "user.dir";
428
429    /**
430     *  The vested system property for the name of the home directory of the
431     *  current user: {@value}.
432     */
433    @API( status = STABLE, since = "0.0.5" )
434    public static final String PROPERTY_USER_HOME = "user.home";
435
436    /**
437     *  The system property for the language code setting the current user:
438     *  {@value}.
439     */
440    @API( status = STABLE, since = "0.0.5" )
441    public static final String PROPERTY_USER_LANG = "user.language";
442
443    /**
444     *  The vested system property for the name of the current user: {@value}.
445     */
446    @API( status = STABLE, since = "0.0.5" )
447    public static final String PROPERTY_USER_NAME = "user.name";
448
449    /**
450     *  The system property for the time zone setting the current user:
451     *  {@value}.
452     */
453    @API( status = STABLE, since = "0.0.6" )
454    public static final String PROPERTY_USER_TIMEZONE = "user.timezone";
455
456    //---* Character sets *----------------------------------------------------
457    /**
458     *  The reference to the ASCII character set.
459     *
460     *  @see StandardCharsets
461     */
462    @API( status = STABLE, since = "0.0.5" )
463    public static final Charset ASCII = StandardCharsets.US_ASCII;
464
465    /**
466     *  The reference to the ISO-8859-1 character set.
467     *
468     *  @see StandardCharsets
469     */
470    @API( status = STABLE, since = "0.0.5" )
471    public static final Charset ISO8859_1 = StandardCharsets.ISO_8859_1;
472
473    /**
474     *  The reference to the US-ASCII character set; this is the same as the
475     *  {@linkplain #ASCII}
476     *  character set.
477     *
478     *  @see StandardCharsets
479     */
480    @API( status = STABLE, since = "0.0.5" )
481    public static final Charset US_ASCII = StandardCharsets.US_ASCII;
482
483    /**
484     *  The reference to the UTF-8 character set.
485     *
486     *  @see StandardCharsets
487     */
488    @API( status = STABLE, since = "0.0.5" )
489    public static final Charset UTF8 = StandardCharsets.UTF_8;
490
491    //---* Timezones *---------------------------------------------------------
492    /**
493     *  The basic time zone (the time zone for the 'Universal Time Code').
494     *
495     *  @deprecated As the {@code java.util.Date} API is now obsolete, also the
496     *      related classes, like {@code java.util.TimeZone} should be used no
497     *      longer.
498     */
499    @Deprecated( since = "0.4.4", forRemoval = true )
500    @SuppressWarnings( "UseOfObsoleteDateTimeApi" )
501    @API( status = DEPRECATED, since = "0.0.5" )
502    public static final TimeZone UTC;
503
504    /**
505     *  The basic time zone (the time zone for the 'Universal Time Code').
506     *
507     *  @deprecated Use
508     *      {@link ZoneOffset#UTC}
509     *      instead.
510     */
511    @Deprecated( since = "0.4.4", forRemoval = false )
512    @API( status = DEPRECATED, since = "0.0.6" )
513    public static final ZoneId ZONE_UTC = ZoneOffset.UTC;
514
515    //---* Constants that are useful in conjunction with XML *-----------------
516    /**
517     *  The lead-in for a CDATA wrapped String: {@value}
518     */
519    @API( status = STABLE, since = "0.0.5" )
520    public static final String CDATA_LEADIN = "<![CDATA[";
521
522    /**
523     *  The lead-out for a CDATA wrapped String: {@value}
524     */
525    @API( status = STABLE, since = "0.0.5" )
526    public static final String CDATA_LEADOUT = "]]>";
527
528    //---* The names of some system thread groups *----------------------------
529    /**
530     *  The name of the main thread group: {@value}.<br>
531     *  <br>This is the group of the main thread.
532     */
533    @API( status = STABLE, since = "0.0.6" )
534    public static final String THREADGROUP_MAIN = "main";
535
536    /**
537     *  The name of the system thread group: {@value}.<br>
538     *  <br>This is the group of several system threads and the parent thread
539     *  group for the main thread group.
540     */
541    @API( status = STABLE, since = "0.0.6" )
542    public static final String THREADGROUP_SYSTEM = "system";
543
544    //---* Often used XML Element and Attribute names *------------------------
545    /**
546     *  The attribute name for an XML attribute holding a category of something:
547     *  {@value}.
548     *
549     *  @see #XMLATTRIBUTE_Type
550     */
551    @API( status = STABLE, since = "0.0.5" )
552    public static final String XMLATTRIBUTE_Category = "category";
553
554    /**
555     *  The attribute name for an XML attribute holding a class name: {@value}.
556     *
557     *  @see #XMLATTRIBUTE_Type
558     */
559    @API( status = STABLE, since = "0.0.5" )
560    public static final String XMLATTRIBUTE_Class = "class";
561
562    /**
563     *  The attribute name for an XML attribute holding a date, usually without
564     *  the time information: {@value}.
565     *
566     *  @see #XMLATTRIBUTE_Time
567     *  @see #XMLATTRIBUTE_Timestamp
568     */
569    @API( status = STABLE, since = "0.0.5" )
570    public static final String XMLATTRIBUTE_Date = "date";
571
572    /**
573     *  The attribute name for an XML attribute holding a file name: {@value}.
574     */
575    @API( status = STABLE, since = "0.0.5" )
576    public static final String XMLATTRIBUTE_File = "file";
577
578    /**
579     *  The attribute name for the XML id attribute: {@value}.
580     */
581    @API( status = STABLE, since = "0.0.5" )
582    public static final String XMLATTRIBUTE_Id = "xml:id";
583
584    /**
585     *  The attribute name for the XML idref attribute: {@value}.
586     */
587    @API( status = STABLE, since = "0.0.5" )
588    public static final String XMLATTRIBUTE_IdRef = "idref";
589
590    /**
591     *  <p>{@summary The attribute name for the XML language attribute:
592     *  {@value}.}</p>
593     *  <p>This reserved attribute takes an ISO639 language identifier as
594     *  value. It indicates the language of the body of the element.</p>
595     */
596    @API( status = STABLE, since = "0.1.0" )
597    public static final String XMLATTRIBUTE_Language = "xml:lang";
598
599    /**
600     *  The attribute name for the XML name attribute: {@value}.<br>
601     *  <br>Only names that follow exact rules for their character set can be
602     *  stored in XML attributes, but free names have to be stored as XML
603     *  elements.
604     *
605     *  @see #XMLELEMENT_Name
606     */
607    @API( status = STABLE, since = "0.0.5" )
608    public static final String XMLATTRIBUTE_Name = "name";
609
610    /**
611     *  The name for the node id XML attribute: {@value}.
612     */
613    @API( status = STABLE, since = "0.0.5" )
614    public static final String XMLATTRIBUTE_NodeId = "node";
615
616    /**
617     *  The name for the PID XML attribute: {@value}.
618     */
619    @API( status = STABLE, since = "0.0.5" )
620    public static final String XMLATTRIBUTE_PID = "pid";
621
622    /**
623     *  The name for the reference XML attribute: {@value}.
624     */
625    @API( status = STABLE, since = "0.0.5" )
626    public static final String XMLATTRIBUTE_Reference = "reference";
627
628    /**
629     *  The name for the sequence number XML attribute: {@value}.
630     */
631    @API( status = STABLE, since = "0.0.5" )
632    public static final String XMLATTRIBUTE_SequenceNumber = "sequenceNumber";
633
634    /**
635     *  The name for the status XML attribute: {@value}.
636     */
637    @API( status = STABLE, since = "0.0.5" )
638    public static final String XMLATTRIBUTE_Status = "status";
639
640    /**
641     *  The attribute name for an XML attribute holding a time, usually without
642     *  the date information: {@value}.
643     *
644     *  @see #XMLATTRIBUTE_Date
645     *  @see #XMLATTRIBUTE_Timestamp
646     */
647    @API( status = STABLE, since = "0.0.5" )
648    public static final String XMLATTRIBUTE_Time = "time";
649
650    /**
651     *  The name for an XML attribute holding a date/time: {@value}.
652     *
653     *  @see #XMLATTRIBUTE_Date
654     *  @see #XMLATTRIBUTE_Time
655     */
656    @API( status = STABLE, since = "0.0.5" )
657    public static final String XMLATTRIBUTE_Timestamp = "timestamp";
658
659    /**
660     *  The name for an XML attribute holding a type, in the sense of a
661     *  <i>category</i> or <i>model</i>, and <i>usually</i> not in the sense
662     *  this term is used in the context of programming languages: {@value}.
663     *
664     *  @see #XMLATTRIBUTE_Category
665     *  @see #XMLATTRIBUTE_Class
666     */
667    @API( status = STABLE, since = "0.0.5" )
668    public static final String XMLATTRIBUTE_Type = "type";
669
670    /**
671     *  The name for the user id XML attribute: {@value}.
672     */
673    @API( status = STABLE, since = "0.0.5" )
674    public static final String XMLATTRIBUTE_UserId = "userId";
675
676    /**
677     *  The name for the version XML attribute: {@value}.
678     */
679    @API( status = STABLE, since = "0.0.5" )
680    public static final String XMLATTRIBUTE_Version = "version";
681
682    /**
683     *  <p>{@summary The attribute name for the XML space attribute:
684     *  {@value}.}</p>
685     *  <p>This reserved attribute indicates whether any whitespace inside the
686     *  element is significant and should not be altered by the XML processor.
687     *  The attribute can take one of two enumerated values:</p>
688     *  <dl>
689     *      <dt>{@code preserve}</dt>
690     *          <dd>The XML application preserves all whitespace (newlines,
691     *          spaces, and tabs) present within the element.</dd>
692     *      <dt>{@code default}</dt>
693     *          <dd>The XML processor uses its default processing rules when
694     *          deciding to preserve or discard the whitespace inside the
695     *          element.</dd>
696     *  </dl>
697     */
698    @API( status = STABLE, since = "0.1.0" )
699    public static final String XMLATTRIBUTE_Whitespace = "xml:space";
700
701    /**
702     *  The element name for an XML element representing a comment:
703     *  {@value}.<br>
704     *  <br>This is not an XML comment (they will be written as
705     *  <code>&lt;!--&nbsp;&hellip;&nbsp;--&gt;</code> in the XML stream) but
706     *  data that is semantically a <i>comment</i> (like a {@code description},
707     *  see
708     *  {@linkplain #XMLELEMENT_Description below}).
709     */
710    @API( status = STABLE, since = "0.0.5" )
711    public static final String XMLELEMENT_Comment = "comment";
712
713    /**
714     *  The element name for an XML element holding a date, usually without
715     *  the time information: {@value}.
716     *
717     *  @see #XMLELEMENT_Time
718     *  @see #XMLELEMENT_Timestamp
719     */
720    @API( status = STABLE, since = "0.0.5" )
721    public static final String XMLELEMENT_Date = "date";
722
723    /**
724     *  The element name for an XML element representing a description of some
725     *  kind: {@value}.
726     */
727    @API( status = STABLE, since = "0.0.5" )
728    public static final String XMLELEMENT_Description = "description";
729
730    /**
731     *  The element name for an XML element containing a message: {@value}.
732     */
733    @API( status = STABLE, since = "0.0.5" )
734    public static final String XMLELEMENT_Message = "message";
735
736    /**
737     *  The element name for an XML element representing a name of some
738     *  kind: {@value}.<br>
739     *  <br>Only names that follow exact rules for their character set can be
740     *  stored in XML attributes, but free names have to be stored as XML
741     *  elements.
742     *
743     *  @see #XMLATTRIBUTE_Name
744     */
745    @API( status = STABLE, since = "0.0.5" )
746    public static final String XMLELEMENT_Name = "name";
747
748    /**
749     *  The element name for an XML element holding text: {@value}.
750     */
751    @API( status = STABLE, since = "0.0.5" )
752    public static final String XMLELEMENT_Text = "text";
753
754    /**
755     *  The element name for an XML element holding a time, usually without
756     *  the date information: {@value}.
757     *
758     *  @see #XMLELEMENT_Date
759     *  @see #XMLELEMENT_Timestamp
760     */
761    @API( status = STABLE, since = "0.0.5" )
762    public static final String XMLELEMENT_Time = "time";
763
764    /**
765     *  The name for an XML element holding a date/time: {@value}.
766     *
767     *  @see #XMLELEMENT_Date
768     *  @see #XMLELEMENT_Time
769     */
770    @API( status = STABLE, since = "0.0.5" )
771    public static final String XMLELEMENT_Timestamp = "timestamp";
772
773    //---* Other useful constants *--------------------------------------------
774    /**
775     *  The line terminator as defined by the underlying operating system.
776     */
777    @API( status = STABLE, since = "0.0.5" )
778    public static final String CR;
779
780    /**
781     *  The decimal separator for the current locale.
782     */
783    @API( status = STABLE, since = "0.0.5" )
784    public static final char DECIMAL_SEPARATOR;
785
786    /**
787     *  The default application id if nothing else could be used: {@value}.
788     */
789    @API( status = STABLE, since = "0.0.5" )
790    public static final String DEFAULT_APPLICATION_ID = "Default Program Main";
791
792    /**
793     *  The empty string.
794     */
795    @API( status = STABLE, since = "0.0.5" )
796    public static final String EMPTY_STRING;
797
798    /**
799     *  An empty char sequence.
800     */
801    @API( status = STABLE, since = "0.0.5" )
802    public static final CharSequence EMPTY_CHARSEQUENCE;
803
804    /**
805     *  The End-Of-File marker for streams: {@value}.
806     */
807    @API( status = STABLE, since = "0.0.5" )
808    public static final int EOF = -1;
809
810    /**
811     *  The index value indicating that nothing was found: {@value}. See for
812     *  example
813     *  {@link String#indexOf(int)}.
814     */
815    @API( status = STABLE, since = "0.1.0" )
816    public static final int NOT_FOUND = -1;
817
818    /**
819     *  A String containing only {@code NUL} (the
820     *  {@link #NULL_CHAR}).
821     */
822    @API( status = STABLE, since = "0.1.0" )
823    public static final String NUL;
824
825    /**
826     *  The null character.
827     */
828    @API( status = STABLE, since = "0.0.5" )
829    public static final char NULL_CHAR;
830
831    /**
832     *  A String containing the sequence &quot;null&quot;.
833     */
834    @API( status = STABLE, since = "0.0.5" )
835    public static final String NULL_STRING;
836
837    /**
838     *  The grouping separator for the current locale, used with large numbers
839     *  to separate thousands.
840     */
841    @API( status = STABLE, since = "0.0.5" )
842    public static final char THOUSANDS_SEPARATOR;
843
844    /**
845     *  A String containing the sequence {@value}.
846     */
847    @API( status = STABLE, since = "0.0.5" )
848    public static final String UNKNOWN_STRING = "<UNKNOWN>";
849
850    //---* Lambdas *-----------------------------------------------------------
851    /**
852     *  Returns {@code true} if the provided reference is {@code null}
853     *  otherwise returns {@code false}.
854     *
855     *  @see Objects#isNull(Object)
856     *  @see Predicate
857     */
858    @API( status = STABLE, since = "0.0.5" )
859    public static final Predicate<? extends Object> IS_NULL = Objects::isNull;
860
861    /**
862     *  Returns {@code true} if the provided reference is non-{@code null}
863     *  otherwise returns {@code false}.
864     *
865     *  @see Objects#nonNull(Object)
866     *  @see Predicate
867     */
868    @API( status = STABLE, since = "0.0.5" )
869    public static final Predicate<? extends Object> NON_NULL = Objects::nonNull;
870
871    //---* Initialise ... *----------------------------------------------------
872    static
873    {
874        CR = lineSeparator();
875
876        final var format = (DecimalFormat) NumberFormat.getInstance();
877        final var symbols = format.getDecimalFormatSymbols();
878        DECIMAL_SEPARATOR = symbols.getDecimalSeparator();
879        THOUSANDS_SEPARATOR = symbols.getGroupingSeparator();
880
881        EMPTY_STRING = "";
882        EMPTY_CHARSEQUENCE = EMPTY_STRING;
883        NULL_CHAR = '\u0000';
884        NUL = Character.toString( NULL_CHAR );
885
886        /*
887         * The cast is required because if omitted, String.valueOf( char [] ) would
888         * be called. This in turn would cause an unwanted NullPointerException.
889         */
890        NULL_STRING = String.valueOf( (Object) null ).intern();
891
892        UTC = TimeZone.getTimeZone( ZONE_UTC );
893    }
894
895        /*--------------*\
896    ====** Constructors **=====================================================
897        \*--------------*/
898    /**
899     *  No instance of this class is allowed.
900     */
901    private CommonConstants() { throw new PrivateConstructorForStaticClassCalledError( CommonConstants.class ); }
902}
903//  class CommonConstants
904
905/*
906 *  End of File
907 */