mirror of https://github.com/apache/poi.git
Minor code improvements, fixed comments
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@723146 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bcfff4072f
commit
db07c3ed7e
|
@ -1,3 +1,20 @@
|
||||||
|
/* ====================================================================
|
||||||
|
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.formula;
|
package org.apache.poi.ss.formula;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -14,9 +31,16 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
||||||
import org.apache.poi.util.LittleEndianInput;
|
import org.apache.poi.util.LittleEndianInput;
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulates an encoded formula token array.
|
||||||
|
*
|
||||||
|
* @author Josh Micich
|
||||||
|
*/
|
||||||
public class Formula {
|
public class Formula {
|
||||||
|
|
||||||
private static final byte[] EMPTY_BYTE_ARRAY = { };
|
private static final Formula EMPTY = new Formula(new byte[0], 0);
|
||||||
|
|
||||||
|
/** immutable */
|
||||||
private final byte[] _byteEncoding;
|
private final byte[] _byteEncoding;
|
||||||
private final int _encodedTokenLen;
|
private final int _encodedTokenLen;
|
||||||
|
|
||||||
|
@ -112,8 +136,8 @@ public class Formula {
|
||||||
* @return Never <code>null</code> (Possibly empty if the supplied <tt>ptgs</tt> is <code>null</code>)
|
* @return Never <code>null</code> (Possibly empty if the supplied <tt>ptgs</tt> is <code>null</code>)
|
||||||
*/
|
*/
|
||||||
public static Formula create(Ptg[] ptgs) {
|
public static Formula create(Ptg[] ptgs) {
|
||||||
if (ptgs == null) {
|
if (ptgs == null || ptgs.length < 1) {
|
||||||
return new Formula(EMPTY_BYTE_ARRAY, 0);
|
return EMPTY;
|
||||||
}
|
}
|
||||||
int totalSize = Ptg.getEncodedSize(ptgs);
|
int totalSize = Ptg.getEncodedSize(ptgs);
|
||||||
byte[] encodedData = new byte[totalSize];
|
byte[] encodedData = new byte[totalSize];
|
||||||
|
@ -136,7 +160,7 @@ public class Formula {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Formula copy() {
|
public Formula copy() {
|
||||||
// OK to return this for the moment because currently immutable
|
// OK to return this because immutable
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue