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