KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > DxLib > DxString


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DxString.java,v 1.6 2000/10/28 16:55:14 daniela Exp $
8

9 package org.ozoneDB.DxLib;
10
11 import java.io.*;
12
13
14 public class DxString extends DxObject implements Externalizable {
15     
16     final static long serialVersionUID = 1L;
17     
18     String JavaDoc value = new String JavaDoc();
19     
20     
21     public DxString() {
22         super();
23     }
24     
25     
26     public DxString( DxString s ) {
27         super();
28         value = new String JavaDoc( s.value );
29     }
30     
31     
32     public DxString( String JavaDoc v ) {
33         super();
34         value = new String JavaDoc( v );
35     }
36     
37     
38     public Object JavaDoc clone() {
39         return new DxString( value );
40     }
41     
42     
43     public boolean equals( String JavaDoc obj ) {
44         return value.equals( obj );
45     }
46     
47     
48     public boolean equals( Object JavaDoc obj ) {
49         if (this == obj) {
50             return true;
51         }
52         if (obj instanceof DxString && obj != null) {
53             return value.equals( ((DxString)obj).value );
54         } else {
55             return false;
56         }
57     }
58     
59     
60     public boolean isLess( DxCompatible obj ) {
61         if (this == obj) {
62             return false;
63         }
64         return value.compareTo( ((DxString)obj).value ) < 0;
65     }
66     
67     
68     public String JavaDoc toString() {
69         return value;
70     }
71     
72     
73     public int hashCode() {
74         //die fehlenden bits dann mit equals()
75
return value.hashCode();
76     }
77     
78     
79     public DxString append( DxString s ) {
80         value += s;
81         return this;
82     }
83     
84     
85     public DxString append( String JavaDoc s ) {
86         return append( new DxString( s ) );
87     }
88     
89     
90     public DxString prepend( DxString s ) {
91         value = s + value;
92         return this;
93     }
94     
95     
96     public DxString prepend( String JavaDoc s ) {
97         return prepend( new DxString( s ) );
98     }
99     
100     
101     public void insertAt( DxString s, int a ) {
102         insertAt( s, a, s.length() );
103     }
104     
105     
106     public void insertAt( String JavaDoc s, int a ) {
107         insertAt( new DxString( s ), a, s.length() );
108     }
109     
110     
111     public void insertAt( DxString s, int a, int len ) {
112         String JavaDoc pre = value.substring( 0, a );
113         String JavaDoc app = value.substring( a, value.length() );
114         value = pre + s.value.substring( 0, len ) + app;
115     }
116     
117     
118     public void insertAt( String JavaDoc s, int a, int len ) {
119         insertAt( new DxString( s ), a, len );
120     }
121     
122     
123     public void deleteAt( int a ) {
124         deleteAt( a, value.length() - a );
125     }
126     
127     
128     public void deleteAt( int a, int len ) {
129         String JavaDoc pre = value.substring( 0, a );
130         String JavaDoc app = value.substring( a + len, value.length() );
131         value = pre + app;
132     }
133     
134     
135     public DxString at( int a, int len ) {
136         return new DxString( value.substring( a, a + len ) );
137     }
138     
139     
140     public int length() {
141         return value.length();
142     }
143     
144     
145     public void writeExternal( ObjectOutput out ) throws IOException {
146         out.writeUTF( value );
147     }
148     
149     
150     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException JavaDoc {
151         value = in.readUTF();
152     }
153     
154 }
155
Popular Tags