Java tutorial
//package com.java2s; /** * Copyright 2009 Welocalize, Inc. * * Licensed 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. * */ import java.util.Hashtable; public class Main { static private Hashtable s_exportBatches = new Hashtable(); /** * Access the Hashtable s_exportBatches to see what the current page count * of this export batch is. This call decrements the value in the table. */ private static boolean isExportFileComplete(String p_fileId, int p_pageCount) { // Default is to write out the file. boolean result = true; int curPageCnt = -1; synchronized (s_exportBatches) { Integer oldPageCount = (Integer) s_exportBatches.get(p_fileId); if (oldPageCount == null) { // First page of this exportBatch. curPageCnt = p_pageCount - 1; if (curPageCnt == 0) { // The batch is complete, no need to put anything // in the hashtable. result = true; } else { result = false; s_exportBatches.put(p_fileId, new Integer(curPageCnt)); } } else { curPageCnt = oldPageCount.intValue() - 1; if (curPageCnt == 0) { // The batch is complete, remove the value from the // hashtable. result = true; s_exportBatches.remove(p_fileId); } else { result = false; s_exportBatches.put(p_fileId, new Integer(curPageCnt)); } } } return result; } }