/[webpac]/openisis/current/org/openisis/Fdt.java
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /openisis/current/org/openisis/Fdt.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 237 - (hide annotations)
Mon Mar 8 17:43:12 2004 UTC (20 years, 1 month ago) by dpavlin
File size: 3919 byte(s)
initial import of openisis 0.9.0 vendor drop

1 dpavlin 237 /*
2     openisis - an open implementation of the CDS/ISIS database
3     Version 0.8.x (patchlevel see file Version)
4     Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
5    
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Lesser General Public
8     License as published by the Free Software Foundation; either
9     version 2.1 of the License, or (at your option) any later version.
10    
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     Lesser General Public License for more details.
15    
16     You should have received a copy of the GNU Lesser General Public
17     License along with this library; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19    
20     see README for more information
21     EOH */
22    
23     package org.openisis;
24    
25     /**
26     Field description table.
27     <p>
28     $Id: Fdt.java,v 1.5 2003/04/08 00:20:53 kripke Exp $
29     @version $Revision: 1.5 $
30     @author $Author: kripke $
31     */
32     public class Fdt {
33    
34     /** alphanum field type. */
35     public static final int FTX = 0;
36     /** strictly alpha field type. */
37     public static final int FTA = 1;
38     /** numeric field type. */
39     public static final int FTN = 2;
40     /** pattern field type. */
41     public static final int FTP = 3;
42     /** iso field type. */
43     public static final int FTI = 10;
44     /** enum field type. */
45     public static final int FTE = 12;
46     /** boolean field type. */
47     public static final int FTB = 13;
48     /** table field type. */
49     public static final int FTT = 14;
50     /** structure field type. */
51     public static final int FTS = 15;
52     /** subfield field type. */
53     public static final int FTF = 16;
54     /** enum value type. */
55     public static final int FTV = 31;
56    
57     /** field description. */
58     public static class Fd {
59     /** tag */
60     public final int id;
61     /** type */
62     public final int type;
63     /** max length or enum value */
64     public final int len;
65     /** repeated flag */
66     public final boolean rep;
67     /** name */
68     public final String name;
69     /** subfields/pattern */
70     public final String subf;
71     /** description */
72     public final String desc;
73    
74     /** @exception IllegalArgumentException if name is null or ""
75     */
76     public Fd (int id, int type, int len, boolean rep,
77     String name, String subf, String desc) {
78     this.id = id;
79     this.type = type;
80     this.len = len;
81     this.rep = rep;
82     this.name = name;
83     this.subf = subf;
84     this.desc = desc;
85     if (null == name || 0 == name.length ()) {
86     throw new IllegalArgumentException (
87     "illegal field desc: id " + id + ", name " + name);
88     }
89     }
90    
91     /** shorthand for Fd (id, type, len, false, name, null, null)
92     */
93     public Fd (int id, int type, int len, String name) {
94     this (id, type, len, false, name, null, null);
95     }
96    
97     public String toString () {
98     return name + ';' + id + ';' + type;
99     }
100     }
101    
102     public final Fd[] _fd;
103    
104     /** @exception IllegalArgumentException if fd is null or has length 0
105     */
106     public Fdt (Fd[] fd) {
107     _fd = fd;
108     if (null == fd || 0 == fd.length) {
109     throw new IllegalArgumentException ();
110     }
111     }
112    
113     public Fd fdById (int id) {
114     for (int j = _fd.length; 0 <= --j; ) {
115     if (id == _fd[j].id) {
116     return _fd[j];
117     }
118     }
119     return null;
120     }
121    
122     public Fd fdByName (String name) {
123     if (null == name || 0 == name.length ()) {
124     return null;
125     }
126     char c = name.charAt (0);
127     if ('0' <= c && '9' >= c) {
128     try {
129     int id = Integer.parseInt (name);
130     return fdById (id);
131     }
132     catch (Exception ex) {
133     }
134     }
135     for (int j = _fd.length; 0 <= --j; ) {
136     if (name.equals (_fd[j].name)) {
137     return _fd[j];
138     }
139     }
140     return null;
141     }
142    
143     public String dump() {
144     StringBuffer d=new StringBuffer();
145     for(int i=0;i<_fd.length;i++) {
146     d.append(_fd[i].toString());
147     if (_fd[i].subf!=null) {
148     d.append(',');
149     d.append(_fd[i].subf);
150     }
151     d.append('\n');
152     }
153     return d.toString();
154     }
155     }
156    

  ViewVC Help
Powered by ViewVC 1.1.26