Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache Commons Lang v3 Source Code Files
Apache Commons Lang 3 is the 3rd version of Apache Commons Lang, which provides a host of helper utilities for the java.lang API.
Apache Commons Lang 3 Source Code files are provided in both binary packge (commons-lang3-3.12.0-bin.zip) and source package (commons-lang3-3.12.0-src.zip). You can download them at Apache Commons Lang Website.
Apache Commons Lang 3 Source Code has no dependencies and is compatible with Java 8 and newer versions. You can compile it to generate your own version of Apache Commons Lang 3 JAR file.
You can also browse the source code below:
✍: FYIcenter
⏎ org/apache/commons/lang3/text/FormattableUtils.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.lang3.text; import static java.util.FormattableFlags.LEFT_JUSTIFY; import java.util.Formattable; import java.util.Formatter; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; /** * <p>Provides utilities for working with the {@code Formattable} interface.</p> * * <p>The {@link Formattable} interface provides basic control over formatting * when using a {@code Formatter}. It is primarily concerned with numeric precision * and padding, and is not designed to allow generalised alternate formats.</p> * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/FormattableUtils.html"> * FormattableUtils</a> instead */ @Deprecated public class FormattableUtils { /** * A format that simply outputs the value as a string. */ private static final String SIMPLEST_FORMAT = "%s"; /** * <p>{@code FormattableUtils} instances should NOT be constructed in * standard programming. Instead, the methods of the class should be invoked * statically.</p> * * <p>This constructor is public to permit tools that require a JavaBean * instance to operate.</p> */ public FormattableUtils() { } //----------------------------------------------------------------------- /** * Gets the default formatted representation of the specified * {@code Formattable}. * * @param formattable the instance to convert to a string, not null * @return the resulting string, not null */ public static String toString(final Formattable formattable) { return String.format(SIMPLEST_FORMAT, formattable); } /** * Handles the common {@code Formattable} operations of truncate-pad-append, * with no ellipsis on precision overflow, and padding width underflow with * spaces. * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} * @param width the width of the output, see {@code Formattable} * @param precision the precision of the output, see {@code Formattable} * @return the {@code formatter} instance, not null */ public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision) { return append(seq, formatter, flags, width, precision, ' ', null); } /** * Handles the common {@link Formattable} operations of truncate-pad-append, * with no ellipsis on precision overflow. * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} * @param width the width of the output, see {@code Formattable} * @param precision the precision of the output, see {@code Formattable} * @param padChar the pad character to use * @return the {@code formatter} instance, not null */ public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final char padChar) { return append(seq, formatter, flags, width, precision, padChar, null); } /** * Handles the common {@link Formattable} operations of truncate-pad-append, * padding width underflow with spaces. * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} * @param width the width of the output, see {@code Formattable} * @param precision the precision of the output, see {@code Formattable} * @param ellipsis the ellipsis to use when precision dictates truncation, null or * empty causes a hard truncation * @return the {@code formatter} instance, not null */ public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final CharSequence ellipsis) { return append(seq, formatter, flags, width, precision, ' ', ellipsis); } /** * Handles the common {@link Formattable} operations of truncate-pad-append. * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} * @param width the width of the output, see {@code Formattable} * @param precision the precision of the output, see {@code Formattable} * @param padChar the pad character to use * @param ellipsis the ellipsis to use when precision dictates truncation, null or * empty causes a hard truncation * @return the {@code formatter} instance, not null */ public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final char padChar, final CharSequence ellipsis) { Validate.isTrue(ellipsis == null || precision < 0 || ellipsis.length() <= precision, "Specified ellipsis '%1$s' exceeds precision of %2$s", ellipsis, Integer.valueOf(precision)); final StringBuilder buf = new StringBuilder(seq); if (precision >= 0 && precision < seq.length()) { final CharSequence _ellipsis = ObjectUtils.defaultIfNull(ellipsis, StringUtils.EMPTY); buf.replace(precision - _ellipsis.length(), seq.length(), _ellipsis.toString()); } final boolean leftJustify = (flags & LEFT_JUSTIFY) == LEFT_JUSTIFY; for (int i = buf.length(); i < width; i++) { buf.insert(leftJustify ? i : 0, padChar); } formatter.format(buf.toString()); return formatter; } }
⏎ org/apache/commons/lang3/text/FormattableUtils.java
Or download all of them as a single archive file:
File name: commons-lang3-3.12.0-sources.jar File size: 651724 bytes Release date: 2020-01-22 Download
⇒ Download and Install commons-lang3-3.8.1-bin.zip
⇐ Download Apache Commons Lang v3 Source Package
2022-10-19, 150706👍, 3💬
Popular Posts:
commons-io-2.6-sources.j aris the source JAR file for Apache Commons IO 2.6, which is a library of u...
What Is mail.jar of JavaMail 1.4? I got the JAR file from javamail-1_4.zip. mail.jar in javamail-1_4...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was develo...
JDK 8 tools.jar is the JAR file for JDK 8 tools. It contains Java classes to support different JDK t...
commons-collections4-4.4 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...