Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
Collections:
Other Resources:
What Is poi-5.2.3.jar?
What Is poi-5.2.3.jar?
✍: FYIcenter.com
poi-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which
provides an API for Microsoft document files of Word, Excel, PowerPoint, and Visio.
poi-5.2.3.jar supports Apache POI components that read and write Microsoft's OLE 2 Compound document format, which is used in early versions of Microsoft Office tools like Word 97, Excel 97, PowerPoint 97, etc.
poi-5.2.3.jar is distributed as part of the poi-bin-5.2.3-20220909.zip download file.
JAR File Size and Download Location:
JAR name: poi-5.2.3.jar Target JDK version: 9 File name: poi.jar, poi-5.2.3.jar File size: 2964641 bytes Release date: 09-09-2022 Download: Apache POI Website
Here are Java Source Code files for poi-5.2.3.jar:
⏎ org/apache/poi/ss/format/CellElapsedFormatter.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.poi.ss.format;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* This class implements printing out an elapsed time format.
*/
public class CellElapsedFormatter extends CellFormatter {
private final List<TimeSpec> specs;
private TimeSpec topmost;
private final String printfFmt;
private static final Pattern PERCENTS = Pattern.compile("%");
private static final double HOUR__FACTOR = 1.0 / 24.0;
private static final double MIN__FACTOR = HOUR__FACTOR / 60.0;
private static final double SEC__FACTOR = MIN__FACTOR / 60.0;
private static class TimeSpec {
final char type;
final int pos;
final int len;
final double factor;
double modBy;
public TimeSpec(char type, int pos, int len, double factor) {
this.type = type;
this.pos = pos;
this.len = len;
this.factor = factor;
modBy = 0;
}
public long valueFor(double elapsed) {
double val;
if (modBy == 0)
val = elapsed / factor;
else
val = elapsed / factor % modBy;
if (type == '0')
return Math.round(val);
else
return (long) val;
}
}
private class ElapsedPartHandler implements CellFormatPart.PartHandler {
// This is the one class that's directly using printf, so it can't use
// the default handling for quoted strings and special characters. The
// only special character for this is '%', so we have to handle all the
// quoting in this method ourselves.
@Override
public String handlePart(Matcher m, String part, CellFormatType type,
StringBuffer desc) {
int pos = desc.length();
char firstCh = part.charAt(0);
switch (firstCh) {
case '[':
if (part.length() < 3)
break;
if (topmost != null)
throw new IllegalArgumentException(
"Duplicate '[' times in format");
part = part.toLowerCase(Locale.ROOT);
int specLen = part.length() - 2;
topmost = assignSpec(part.charAt(1), pos, specLen);
return part.substring(1, 1 + specLen);
case 'h':
case 'm':
case 's':
case '0':
part = part.toLowerCase(Locale.ROOT);
assignSpec(part.charAt(0), pos, part.length());
return part;
case '\n':
return "%n";
case '\"':
part = part.substring(1, part.length() - 1);
break;
case '\\':
part = part.substring(1);
break;
case '*':
if (part.length() > 1)
part = CellFormatPart.expandChar(part);
break;
// An escape we can let it handle because it can't have a '%'
case '_':
return null;
}
// Replace ever "%" with a "%%" so we can use printf
return PERCENTS.matcher(part).replaceAll("%%");
}
}
/**
* Creates a elapsed time formatter.
*
* @param pattern The pattern to parse.
*/
public CellElapsedFormatter(String pattern) {
super(pattern);
specs = new ArrayList<>();
StringBuffer desc = CellFormatPart.parseFormat(pattern,
CellFormatType.ELAPSED, new ElapsedPartHandler());
ListIterator<TimeSpec> it = specs.listIterator(specs.size());
while (it.hasPrevious()) {
TimeSpec spec = it.previous();
desc.replace(spec.pos, spec.pos + spec.len, "%0" + spec.len + "d");
if (spec.type != topmost.type) {
spec.modBy = modFor(spec.type, spec.len);
}
}
printfFmt = desc.toString();
}
private TimeSpec assignSpec(char type, int pos, int len) {
TimeSpec spec = new TimeSpec(type, pos, len, factorFor(type, len));
specs.add(spec);
return spec;
}
private static double factorFor(char type, int len) {
switch (type) {
case 'h':
return HOUR__FACTOR;
case 'm':
return MIN__FACTOR;
case 's':
return SEC__FACTOR;
case '0':
return SEC__FACTOR / Math.pow(10, len);
default:
throw new IllegalArgumentException(
"Uknown elapsed time spec: " + type);
}
}
private static double modFor(char type, int len) {
switch (type) {
case 'h':
return 24;
case 'm':
case 's':
return 60;
case '0':
return Math.pow(10, len);
default:
throw new IllegalArgumentException(
"Uknown elapsed time spec: " + type);
}
}
@Override
public void formatValue(StringBuffer toAppendTo, Object value) {
double elapsed = ((Number) value).doubleValue();
if (elapsed < 0) {
toAppendTo.append('-');
elapsed = -elapsed;
}
Object[] parts = new Long[specs.size()];
for (int i = 0; i < specs.size(); i++) {
parts[i] = specs.get(i).valueFor(elapsed);
}
try (Formatter formatter = new Formatter(toAppendTo, Locale.ROOT)) {
formatter.format(printfFmt, parts);
}
}
/**
* {@inheritDoc}
* <p>
* For a date, this is {@code "mm/d/y"}.
*/
@Override
public void simpleValue(StringBuffer toAppendTo, Object value) {
formatValue(toAppendTo, value);
}
}
⏎ org/apache/poi/ss/format/CellElapsedFormatter.java
Or download all of them as a single archive file:
File name: poi-5.2.3-src.zip File size: 2479830 bytes Release date: 2022-09-09 Download
⇒ What Is poi-ooxml-5.2.3.jar?
⇐ What Is poi-bin-5.2.3-20220909.zip?
2017-04-04, ≈385🔥, 0💬
Popular Posts:
If you are a Java developer, it is very often that you need to use some 3rd party libraries to perfo...
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
jTDS JDBC Driver Source Code Files are provided in the source package file, jtds-1.3.1-fyi.zip. You ...
What Is commons-fileupload-1.3.3 .jar?commons-fileupload-1.3.3 .jaris the JAR file for Apache Common...
Where to get the Java source code for Connector/J 8.0 Core API module? Java source code files for Co...