01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: IndexIdentifier.java,v 1.4 2003/02/26 00:22:50 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: class IndexIdentifier extends SQLIdentifier {
14: public static final int MAX_INDICES = 36;
15:
16: public IndexIdentifier(BaseTable table, boolean isUnique, int seq) {
17: super (table.getStoreManager().getDatabaseAdapter());
18:
19: this .javaName = null;
20:
21: String suffix = isUnique ? "_U" : "_N";
22:
23: if (seq < 10)
24: suffix += (char) ('0' + seq);
25: else if (seq < MAX_INDICES)
26: suffix += (char) ('A' + seq);
27: else
28: throw new TooManyIndicesException(table);
29:
30: String baseID = truncate(table.getName().getSQLIdentifier(),
31: getMaxLength() - 4);
32:
33: setSQLIdentifier(baseID + suffix);
34: }
35:
36: protected int getMaxLength() {
37: return dba.getMaxIndexNameLength();
38: }
39: }
|