1 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 value = new String (); 19 20 21 public DxString() { 22 super(); 23 } 24 25 26 public DxString( DxString s ) { 27 super(); 28 value = new String ( s.value ); 29 } 30 31 32 public DxString( String v ) { 33 super(); 34 value = new String ( v ); 35 } 36 37 38 public Object clone() { 39 return new DxString( value ); 40 } 41 42 43 public boolean equals( String obj ) { 44 return value.equals( obj ); 45 } 46 47 48 public boolean equals( Object 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 toString() { 69 return value; 70 } 71 72 73 public int hashCode() { 74 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 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 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 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 pre = value.substring( 0, a ); 113 String app = value.substring( a, value.length() ); 114 value = pre + s.value.substring( 0, len ) + app; 115 } 116 117 118 public void insertAt( String 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 pre = value.substring( 0, a ); 130 String 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 { 151 value = in.readUTF(); 152 } 153 154 } 155 | Popular Tags |