KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > om > DocumentNumberAllocator


1 package net.sf.saxon.om;
2
3 import java.io.Serializable JavaDoc;
4
5 /**
6  * This class (which has one instance per Configuration) is used to allocate unique document
7  * numbers. It's a separate class so that it can act as a monitor for synchronization
8  */

9 public class DocumentNumberAllocator implements Serializable JavaDoc {
10
11     private int nextDocumentNumber = 0;
12
13     /**
14      * Allocate a unique document number
15      * @return a unique document number
16      */

17
18     public synchronized int allocateDocumentNumber() {
19         return nextDocumentNumber++;
20     }
21 }
22
23 //
24
// The contents of this file are subject to the Mozilla Public License Version
25
// 1.0 (the "License");
26
// you may not use this file except in compliance with the License. You may
27
// obtain a copy of the
28
// License at http://www.mozilla.org/MPL/
29
//
30
// Software distributed under the License is distributed on an "AS IS" basis,
31
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
32
// See the License for the specific language governing rights and limitations
33
// under the License.
34
//
35
// The Original Code is: all this file.
36
//
37
// The Initial Developer of the Original Code is Michael Kay, with extensive
38
// rewriting by Wolfgang Hoschek
39
//
40
// Portions created by (your name) are Copyright (C) (your legal entity). All
41
// Rights Reserved.
42
//
43
// Contributor(s): none.
44
//
45
Popular Tags