source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/metadata/AbstractIdentifierFactory.java@ 12188

Last change on this file since 12188 was 12188, checked in by kjdon, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 687 bytes
Line 
1package org.greenstone.gsdl3.gs3build.metadata;
2
3public abstract class AbstractIdentifierFactory
4{
5 private String idPrelude;
6 private int idSeqNo;
7
8 public AbstractIdentifierFactory(String idPrelude)
9 { this.idPrelude = idPrelude;
10 this.idSeqNo = 1;
11 }
12
13 public String getNextIdentifier()
14 { int id = this.idSeqNo ++;
15
16 return idPrelude + Integer.toString(id);
17 }
18
19 public void noteIdentifier(String identifier)
20 { if (!identifier.startsWith(this.idPrelude))
21 return;
22
23 identifier = identifier.substring(this.idPrelude.length());
24
25 int value = Integer.parseInt(identifier);
26 if (value >= this.idSeqNo) {
27 this.idSeqNo = value + 1;
28 }
29 }
30}
Note: See TracBrowser for help on using the repository browser.