GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rJava/src/java/RectangularArrayBuilder.java at master · s-u/rJava

Expand file tree

/

RectangularArrayBuilder.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
188 lines (166 loc) · 6.4 KB
/

RectangularArrayBuilder.java

Copy path

File metadata and controls

188 lines (166 loc) · 6.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1:
import java.lang.reflect.Array ;
/**
* Builds rectangular java arrays
*/
public class RectangularArrayBuilder extends RJavaArrayIterator {
// {{{ constructors
/**
* constructor
*
* @param payload one dimensional array
* @param dimensions target dimensions
* @throws NotAnArrayException if payload is not an array
*/
public RectangularArrayBuilder( Object payload, int[] dimensions) throws NotAnArrayException, ArrayDimensionException {
super( dimensions ) ;
if( !RJavaArrayTools.isArray(payload) ){
throw new NotAnArrayException( payload.getClass() ) ;
}
if( !RJavaArrayTools.isSingleDimensionArray(payload)){
throw new ArrayDimensionException( "not a single dimension array : " + payload.getClass() ) ;
}
if( dimensions.length == 1 ){
array = payload ;
} else{
String typeName = RJavaArrayTools.getObjectTypeName( payload );
Class clazz = null ;
try{
clazz = RJavaArrayTools.getClassForSignature( typeName, payload.getClass().getClassLoader() );
} catch( ClassNotFoundException e){/* should not happen */}
array = Array.newInstance( clazz , dimensions ) ;
if( typeName.equals( "I" ) ){
fill_int( (int[])payload ) ;
} else if( typeName.equals( "Z" ) ){
fill_boolean( (boolean[])payload ) ;
} else if( typeName.equals( "B" ) ){
fill_byte( (byte[])payload ) ;
} else if( typeName.equals( "J" ) ){
fill_long( (long[])payload ) ;
} else if( typeName.equals( "S" ) ){
fill_short( (short[])payload ) ;
} else if( typeName.equals( "D" ) ){
fill_double( (double[])payload ) ;
} else if( typeName.equals( "C" ) ){
fill_char( (char[])payload ) ;
} else if( typeName.equals( "F" ) ){
fill_float( (float[])payload ) ;
} else{
fill_Object( (Object[])payload ) ;
}
}
}
public RectangularArrayBuilder( Object payload, int length ) throws NotAnArrayException, ArrayDimensionException{
this( payload, new int[]{ length } ) ;
}
// java < 1.5 kept happy
public RectangularArrayBuilder(int x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; }
public RectangularArrayBuilder(boolean x, int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; }
public RectangularArrayBuilder(byte x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; }
public RectangularArrayBuilder(long x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; }
public RectangularArrayBuilder(short x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; }
public RectangularArrayBuilder(double x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; }
public RectangularArrayBuilder(char x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; }
public RectangularArrayBuilder(float x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; }
public RectangularArrayBuilder(int x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; }
public RectangularArrayBuilder(boolean x, int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; }
public RectangularArrayBuilder(byte x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; }
public RectangularArrayBuilder(long x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; }
public RectangularArrayBuilder(short x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; }
public RectangularArrayBuilder(double x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; }
public RectangularArrayBuilder(char x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; }
public RectangularArrayBuilder(float x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; }
// }}}
// {{{ fill_**
private void fill_int( int[] payload ){
int k;
while( hasNext() ){
int[] current = (int[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_boolean( boolean[] payload ){
int k;
while( hasNext() ){
boolean[] current = (boolean[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_byte( byte[] payload ){
int k;
while( hasNext() ){
byte[] current = (byte[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_long( long[] payload ){
int k;
while( hasNext() ){
long[] current = (long[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_short( short[] payload ){
int k;
while( hasNext() ){
short[] current = (short[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_double( double[] payload ){
int k;
while( hasNext() ){
double[] current = (double[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_char( char[] payload ){
int k;
while( hasNext() ){
char[] current = (char[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_float( float[] payload ){
int k;
while( hasNext() ){
float[] current = (float[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
private void fill_Object( Object[] payload ){
int k;
while( hasNext() ){
Object[] current = (Object[])next() ;
k = start ;
for( int j=0; j<current.length; j++, k+=increment){
current[j] = payload[k];
}
}
}
// }}}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.