<commit_before>/*
 * 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.pdfbox.cos;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.pdfbox.exceptions.COSVisitorException;

/**
 * This class represents an integer number in a PDF document.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Revision: 1.12 $
 */
public class COSInteger extends COSNumber
{

    /**
     * The lowest integer to be kept in the {@link #STATIC} array.
     */
    private static int LOW = -100;

    /**
     * The highest integer to be kept in the {@link #STATIC} array.
     */
    private static int HIGH = 256;

    /**
     * Static instances of all COSIntegers in the range from {@link #LOW}
     * to {@link #HIGH}.
     */
    private static final COSInteger[] STATIC = new COSInteger[HIGH - LOW + 1];

    /** Constant for the number zero. */
    public static final COSInteger ZERO = get(0); 

    /** Constant for the number one. */
    public static final COSInteger ONE = get(1); 

    /** Constant for the number two. */
    public static final COSInteger TWO = get(2); 

    /** Constant for the number three. */
    public static final COSInteger THREE = get(3); 

    /**
     * Returns a COSInteger instance with the given value.
     *
     * @param val integer value
     * @return COSInteger instance
     */
    public static COSInteger get(long val) {
        if (LOW <= val && val <= HIGH) {
            int index = (int) val - LOW;
            // no synchronization needed
            if (STATIC[index] == null) {
                STATIC[index] = new COSInteger(val);
            }
            return STATIC[index];
        } else {
            return new COSInteger(val);
        }
    }

    private long value;

    /**
     * constructor.
     *
     * @deprecated use the static {@link #get(long)} method instead
     * @param val The integer value of this object.
     */<commit_msg>PDFBOX-637: problem with static code in COSInteger/COSNumber<commit_after>/*
 * 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.pdfbox.cos;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.pdfbox.exceptions.COSVisitorException;

/**
 * This class represents an integer number in a PDF document.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Revision: 1.12 $
 */
public class COSInteger extends COSNumber
{

    /**
     * The lowest integer to be kept in the {@link #STATIC} array.
     */
    private static int LOW = -100;

    /**
     * The highest integer to be kept in the {@link #STATIC} array.
     */
    private static int HIGH = 256;

    /**
     * Static instances of all COSIntegers in the range from {@link #LOW}
     * to {@link #HIGH}.
     */
    private static final COSInteger[] STATIC = new COSInteger[HIGH - LOW + 1];

    /**
     * Constant for the number zero.
     * @since Apache PDFBox 1.1.0
     */
    public static final COSInteger ZERO = get(0); 

    /**
     * Constant for the number one.
     * @since Apache PDFBox 1.1.0
     */
    public static final COSInteger ONE = get(1); 

    /**
     * Constant for the number two.
     * @since Apache PDFBox 1.1.0
     */
    public static final COSInteger TWO = get(2); 

    /**
     * Constant for the number three.
     * @since Apache PDFBox 1.1.0
     */
    public static final COSInteger THREE = get(3); 

    /**
     * Returns a COSInteger instance with the given value.
     *
     * @param val integer value
     * @return COSInteger instance
     */
    public static COSInteger get(long val) {
        if (LOW <= val && val <= HIGH) {
            int index = (int) val - LOW;
            // no synchronization needed
            if (STATIC[index] == null) {
                STATIC[index] = new COSInteger(val);
            }
            return STATIC[index];
        } else {
            return new COSInteger(val);
        }
    }

    private long value;

    /**
     * constructor.
     *
     * @deprecated use the static {@link #get(long)} method instead
     * @param val The integer value of this object.
     */
{'fraction_non_alphanumeric': 0.09653333333333333, 'fraction_numerical': 0.009066666666666667, 'mean_word_length': 2.449417535254445, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4818248', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1497, 'n_words': 634}