- Timestamp:
- 03/11/11 15:26:38 (7 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
bindings/java/native/NexusFile.c (modified) (8 diffs)
-
bindings/java/org/nexusformat/NeXusFileInterface.java (modified) (30 diffs)
-
bindings/java/org/nexusformat/NexusFile.java (modified) (26 diffs)
-
include/napi.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/java/native/NexusFile.c
r1661 r1734 3 3 Java API. 4 4 5 Mark Koennecke, October 2000 6 7 Version: 1.0 8 9 Version 1.1 10 11 Updated for using both HDF5 and HDF4 12 13 Mark Koennecke, August 2001 14 15 Updated for the NeXus XML-API, Mark Koennecke, October 2004 16 17 Updated for NXopengrouppath, NXopensourcepath 18 Mark Koennecke, December 2004 19 20 Updated for external linking, Mark Koennecke, April 2006 21 22 Updated for 64 bit types, Mark Koennecke, August 2007 23 24 Added NXinitattrdir and NXinitgroupdir, Mark Koennecke, October 2009 25 26 Added NXgetpath, Mark Koennecke, October 2009 5 Mark Koennecke, 2000 -- 2011 27 6 28 7 IMPLEMENTATION NOTES … … 405 384 } 406 385 } 386 /*------------------------------------------------------------------------ 387 nxmakedata64 388 --------------------------------------------------------------------------*/ 389 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxmakedata64 390 (JNIEnv *env, jobject obj, jint handle, jstring name, jint type, 391 jint rank, jlongArray dim) 392 { 393 char *Name; 394 NXhandle nxhandle; 395 jlong *iDim; 396 int iRet; 397 398 /* set error handler */ 399 NXMSetTError(env,JapiError); 400 401 /* exchange the Java handler to a NXhandle */ 402 nxhandle = (NXhandle)HHGetPointer(handle); 403 404 /* extract the name and class to char * */ 405 Name = (char *) (*env)->GetStringUTFChars(env,name,0); 406 407 /* access dim array */ 408 iDim = (*env)->GetLongArrayElements(env,dim,0); 409 410 iRet = NXmakedata64(nxhandle,Name,type,rank,iDim); 411 412 /* clean up */ 413 (*env)->ReleaseStringUTFChars(env,name, Name); 414 (*env)->ReleaseLongArrayElements(env,dim,iDim,0); 415 416 if (iRet != NX_OK) { 417 JapiError(env, "NXmakedata failed"); 418 } 419 } 407 420 /*----------------------------------------------------------------------- 408 421 nxcompmakedata … … 439 452 (*env)->ReleaseIntArrayElements(env,dim,iDim,0); 440 453 (*env)->ReleaseIntArrayElements(env,chunk,iChunk,0); 454 455 if (iRet != NX_OK) { 456 JapiError(env, "NXcompmakedata failed"); 457 } 458 } 459 460 /*----------------------------------------------------------------------- 461 nxcompmakedata64 462 -------------------------------------------------------------------------*/ 463 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxmakecompdata64 464 (JNIEnv *env, jobject obj, jint handle, jstring name, jint type, 465 jint rank, jlongArray dim, jint compression_type, jlongArray chunk) 466 { 467 char *Name; 468 NXhandle nxhandle; 469 jlong *iDim, *iChunk; 470 int iRet; 471 472 /* set error handler */ 473 NXMSetTError(env,JapiError); 474 475 /* exchange the Java handler to a NXhandle */ 476 nxhandle = (NXhandle)HHGetPointer(handle); 477 478 /* extract the name and class to char * */ 479 Name = (char *) (*env)->GetStringUTFChars(env,name,0); 480 481 /* access dim array */ 482 iDim = (*env)->GetLongArrayElements(env,dim,0); 483 484 /* access the chunksize array */ 485 iChunk = (*env)->GetLongArrayElements(env,chunk,0); 486 487 iRet = NXcompmakedata64(nxhandle,Name,type,rank,iDim, 488 compression_type,iChunk); 489 490 /* clean up */ 491 (*env)->ReleaseStringUTFChars(env,name, Name); 492 (*env)->ReleaseLongArrayElements(env,dim,iDim,0); 493 (*env)->ReleaseLongArrayElements(env,chunk,iChunk,0); 441 494 442 495 if (iRet != NX_OK) { … … 577 630 (*env)->ReleaseIntArrayElements(env,start,iStart,0); 578 631 (*env)->ReleaseIntArrayElements(env,end,iEnd,0); 632 633 if (iRet != NX_OK) { 634 JapiError(env, "NXputslab failed"); 635 } 636 } 637 /*------------------------------------------------------------------------ 638 nxputslab64 639 --------------------------------------------------------------------------*/ 640 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxputslab64 641 (JNIEnv *env, jobject obj, jint handle, jbyteArray data, 642 jlongArray start, jlongArray end) 643 { 644 NXhandle nxhandle; 645 jbyte *bdata; 646 jlong *iStart, *iEnd; 647 int iRet; 648 649 /* set error handler */ 650 NXMSetTError(env,JapiError); 651 652 /* exchange the Java handler to a NXhandle */ 653 nxhandle = (NXhandle)HHGetPointer(handle); 654 655 /* convert arrays to C types */ 656 bdata = (*env)->GetByteArrayElements(env,data,0); 657 iStart = (*env)->GetLongArrayElements(env,start,0); 658 iEnd = (*env)->GetLongArrayElements(env,end,0); 659 660 661 iRet = NXputslab64(nxhandle, bdata, iStart, iEnd); 662 663 /* cleanup */ 664 (*env)->ReleaseByteArrayElements(env,data,bdata,0); 665 (*env)->ReleaseLongArrayElements(env,start,iStart,0); 666 (*env)->ReleaseLongArrayElements(env,end,iEnd,0); 579 667 580 668 if (iRet != NX_OK) { … … 708 796 } 709 797 /*------------------------------------------------------------------------ 798 nxgetslab64 799 --------------------------------------------------------------------------*/ 800 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxgetslab64 801 (JNIEnv *env, jobject obj, jint handle, jlongArray start, 802 jlongArray end, jbyteArray data) 803 { 804 NXhandle nxhandle; 805 jbyte *bdata; 806 jlong *iStart, *iEnd; 807 int iRet; 808 809 /* set error handler */ 810 NXMSetTError(env,JapiError); 811 812 /* exchange the Java handler to a NXhandle */ 813 nxhandle = (NXhandle)HHGetPointer(handle); 814 815 /* convert arrays to C types */ 816 bdata = (*env)->GetByteArrayElements(env,data,0); 817 iStart = (*env)->GetLongArrayElements(env,start,0); 818 iEnd = (*env)->GetLongArrayElements(env,end,0); 819 820 iRet = NXgetslab64(nxhandle, bdata, iStart, iEnd); 821 822 /* cleanup */ 823 (*env)->ReleaseByteArrayElements(env,data,bdata,0); 824 (*env)->ReleaseLongArrayElements(env,start,iStart,0); 825 (*env)->ReleaseLongArrayElements(env,end,iEnd,0); 826 827 if (iRet != NX_OK) { 828 JapiError(env, "NXgetslab failed"); 829 } 830 } 831 /*------------------------------------------------------------------------ 710 832 nxgetattr 711 833 --------------------------------------------------------------------------*/ … … 1190 1312 } 1191 1313 /*------------------------------------------------------------------------ 1314 nxgetinfo64 1315 --------------------------------------------------------------------------*/ 1316 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxgetinfo64 1317 (JNIEnv *env, jobject obj, jint handle, jlongArray dim, jintArray args) 1318 { 1319 int rank, type, iRet, i; 1320 jlong iDim[NX_MAXRANK]; 1321 NXhandle nxhandle; 1322 jlong *jdata; 1323 jint *jargsdata; 1324 1325 /* set error handler */ 1326 NXMSetTError(env,JapiError); 1327 1328 /* exchange the Java handler to a NXhandle */ 1329 nxhandle = (NXhandle)HHGetPointer(handle); 1330 1331 /* call */ 1332 iRet = NXgetinfo64(nxhandle, &rank, iDim, &type); 1333 1334 /* copy data to Java types */ 1335 if(iRet == NX_OK) 1336 { 1337 jdata = (*env)->GetLongArrayElements(env,dim,0); 1338 for(i = 0; i < rank; i++) 1339 { 1340 jdata[i] = iDim[i]; 1341 } 1342 (*env)->ReleaseLongArrayElements(env,dim,jdata,0); 1343 1344 jargsdata = (*env)->GetIntArrayElements(env,args,0); 1345 jargsdata[0] = rank; 1346 jargsdata[1] = type; 1347 (*env)->ReleaseIntArrayElements(env,args,jargsdata,0); 1348 } 1349 } 1350 /*------------------------------------------------------------------------ 1192 1351 nextentry 1193 1352 --------------------------------------------------------------------------*/ … … 1296 1455 } 1297 1456 /*------------------------------------------------------------------------*/ 1457 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_nxlinkexternaldataset 1458 (JNIEnv *env, jobject obj, jint handle, jstring name, jstring nxurl){ 1459 int iRet; 1460 NXhandle nxhandle; 1461 char *Name, *Nxurl; 1462 1463 /* set error handler */ 1464 NXMSetTError(env,JapiError); 1465 1466 /* exchange the Java handler to a NXhandle */ 1467 nxhandle = (NXhandle)HHGetPointer(handle); 1468 1469 /* extract the name and class to char * */ 1470 Name = (char *) (*env)->GetStringUTFChars(env,name,0); 1471 Nxurl = (char *) (*env)->GetStringUTFChars(env,nxurl,0); 1472 iRet = NXlinkexternaldataset(nxhandle,Name,Nxurl); 1473 1474 /* release strings */ 1475 (*env)->ReleaseStringUTFChars(env,name, Name); 1476 (*env)->ReleaseStringUTFChars(env,nxurl, Nxurl); 1477 1478 if (iRet != NX_OK) { 1479 JapiError(env, "NXlinkexternaldataset failed"); 1480 } 1481 } 1482 /*------------------------------------------------------------------------*/ 1298 1483 JNIEXPORT jint JNICALL Java_org_nexusformat_NexusFile_nxisexternalgroup 1299 1484 (JNIEnv *env, jobject obj, jint handle, jstring name, jstring nxclass, … … 1326 1511 return status; 1327 1512 } 1513 /*------------------------------------------------------------------------*/ 1514 JNIEXPORT jint JNICALL Java_org_nexusformat_NexusFile_nxisexternaldataset 1515 (JNIEnv *env, jobject obj, jint handle, jstring name, jobjectArray jnames){ 1516 int status, length = 1024; 1517 NXhandle nxhandle; 1518 char *Name, nxurl[1024]; 1519 jstring rstring; 1520 1521 /* set error handler */ 1522 NXMSetTError(env,JapiError); 1523 1524 /* exchange the Java handler to a NXhandle */ 1525 nxhandle = (NXhandle)HHGetPointer(handle); 1526 1527 /* extract the name and class to char * */ 1528 Name = (char *) (*env)->GetStringUTFChars(env,name,0); 1529 1530 status = NXisexternaldataset(nxhandle,Name,nxurl,length); 1531 1532 /* release strings */ 1533 (*env)->ReleaseStringUTFChars(env,name, Name); 1534 1535 if(status == NX_OK){ 1536 rstring = (*env)->NewStringUTF(env,nxurl); 1537 (*env)->SetObjectArrayElement(env,jnames,0,(jobject)rstring); 1538 } 1539 return status; 1540 } 1328 1541 /*---------------------------------------------------------------------*/ 1329 1542 JNIEXPORT void JNICALL Java_org_nexusformat_NexusFile_initattrdir -
trunk/bindings/java/org/nexusformat/NeXusFileInterface.java
r1465 r1734 11 11 * 12 12 * 13 * @author Mark Koennecke, October 2000 14 * 15 * updated for NAPI-2.0, including HDF-5 support 16 * @author Mark Koennecke, August 2001 17 * 18 * updated for NXopengrouppath, NXopensourcepath, XML 19 * @author Mark Koennecke, December 2004 13 * @author Mark Koennecke, 2000 -- 2011 20 14 * 21 15 * copyright: see accompanying COPYRIGHT file … … 34 28 */ 35 29 public void flush() throws NexusException; 30 36 31 /** 37 32 * finalize closes the file. It is supposed to be called by the … … 44 39 */ 45 40 public void finalize() throws Throwable; 41 46 42 /** 47 43 * close the NeXus file. To make javalint and diamond happy … … 49 45 */ 50 46 public void close() throws NexusException; 47 51 48 // group functions 52 49 /** … … 77 74 * @exception NexusException when something goes wrong. 78 75 */ 79 public void openpath(String path) throws 80 NexusException; 76 public void openpath(String path) throws NexusException; 77 81 78 /** 82 79 * opengrouppath opens groups and datsets accroding to the path string … … 87 84 * @exception NexusException when something goes wrong. 88 85 */ 89 public void opengrouppath(String path) throws 90 NexusException; 86 public void opengrouppath(String path) throws NexusException; 87 91 88 /** 92 89 * return the current path into the NeXus file in the … … 95 92 */ 96 93 public String getpath() throws NexusException; 94 97 95 /** 98 96 * closegroup closes access to the current group and steps down one … … 101 99 * operation. 102 100 */ 103 public void closegroup() throws 104 NexusException; 101 public void closegroup() throws NexusException; 105 102 106 103 // data set handling … … 113 110 * @param rank The rank or number of dimensions of the dataset. 114 111 * @param dim An array containing the length of each dimension. dim must 115 * have at least rank entries. The first dimension can be -1 which116 * means it is anunlimited dimension.112 * have at least rank entries. Dimension passed as -1 denote an 113 * unlimited dimension. 117 114 * @exception NexusException when the dataset could not be created. 118 115 */ 119 116 public void makedata(String name, int type, int rank, int dim[]) 120 117 throws NexusException; 118 119 /** 120 * makedata creates a new dataset with the specified characteristics 121 * in the current group. 122 * @param name The name of the dataset. 123 * @param type The number type of the dataset. Usually a constant from 124 * a selection of values. 125 * @param rank The rank or number of dimensions of the dataset. 126 * @param dim An array containing the length of each dimension. dim must 127 * have at least rank entries. Dimension passed as -1 denote an 128 * unlimited dimension. 129 * @exception NexusException when the dataset could not be created. 130 */ 131 public void makedata(String name, int type, int rank, long dim[]) 132 throws NexusException; 133 121 134 /** 122 135 * compmakedata creates a new dataset with the specified characteristics … … 127 140 * @param rank The rank or number of dimensions of the dataset. 128 141 * @param dim An array containing the length of each dimension. dim must 129 * have at least rank entries. The first dimension can be -1 which130 * means it is anunlimited dimension.142 * have at least rank entries. Dimension passed as -1 denote an 143 * unlimited dimension. 131 144 * @param compression_type determines the compression type. 132 145 * @param iChunk With HDF-5, slabs can be written to compressed data … … 137 150 */ 138 151 public void compmakedata(String name, int type, int rank, int dim[], 139 int compression_type, int iChunk[]) throws 140 NexusException; 152 int compression_type, int iChunk[]) throws NexusException; 153 154 /** 155 * compmakedata creates a new dataset with the specified characteristics 156 * in the current group. This data set will be compressed. 157 * @param name The name of the dataset. 158 * @param type The number type of the dataset. Usually a constant from 159 * a selection of values. 160 * @param rank The rank or number of dimensions of the dataset. 161 * @param dim An array containing the length of each dimension. dim must 162 * have at least rank entries. Dimension passed as -1 denote an 163 * unlimited dimension. 164 * @param compression_type determines the compression type. 165 * @param iChunk With HDF-5, slabs can be written to compressed data 166 * sets. The size of these slabs is specified through the chunk array. 167 * This must have the rank values for the size of the chunk to 168 * be written in each dimension. 169 * @exception NexusException when the dataset could not be created. 170 */ 171 public void compmakedata(String name, int type, int rank, long dim[], 172 int compression_type, long iChunk[]) throws NexusException; 173 141 174 /** 142 175 * opendata opens an existing dataset for access. For instance for … … 146 179 * something else is wrong. 147 180 */ 148 public void opendata(String name)throws 149 NexusException; 181 public void opendata(String name)throws NexusException; 182 150 183 /** 151 184 * closedata closes an opened dataset. Then no further access is … … 153 186 * @exception NexusException when an HDF error occurrs. 154 187 */ 155 public void closedata() throws 156 NexusException; 188 public void closedata() throws NexusException; 189 157 190 /** 158 191 * causes the currently open dataset to be compressed on file. … … 164 197 * occurs. 165 198 */ 166 public void compress(int compression_type) throws 167 NexusException; 199 public void compress(int compression_type) throws NexusException; 168 200 169 201 // data set reading … … 178 210 * the data. 179 211 */ 180 public void getdata(Object array) throws181 NexusException; 212 public void getdata(Object array) throws NexusException; 213 182 214 /** 183 215 * getslab reads a subset of a large dataset into array. … … 191 223 * the data. 192 224 */ 193 public void getslab(int start[], int size[],Object array)throws 194 NexusException; 225 public void getslab(int start[], int size[], Object array) throws 226 NexusException; 227 228 /** 229 * getslab reads a subset of a large dataset into array. 230 * @param start An array of dimension rank which contains the start 231 * position in the dataset from where to start reading. 232 * @param size An array of dimension rank which contains the size 233 * in each dimension of the data subset to read. 234 * @param array An array for holding the returned data values. 235 * @exception NexusException when either an HDF error occurs or 236 * no dataset is open or array is not of the right type to hold 237 * the data. 238 */ 239 public void getslab(long start[], long size[], Object array) throws 240 NexusException; 241 195 242 /** 196 243 * getattr retrieves the data associated with the attribute … … 205 252 * the attribute could not be found. 206 253 */ 207 public void getattr(String name, Object data, int args[])throws254 public void getattr(String name, Object data, int args[]) throws 208 255 NexusException; 209 256 … … 215 262 * @exception NexusException when an HDF error occurs. 216 263 */ 217 public void putdata(Object array) throws 218 NexusException; 264 public void putdata(Object array) throws NexusException; 265 219 266 /** 220 267 * putslab writes a subset of a larger dataset to a previously opened … … 229 276 public void putslab(Object array, int start[], int size[]) throws 230 277 NexusException; 278 279 /** 280 * putslab writes a subset of a larger dataset to a previously opened 281 * dataset. 282 * @param array The data to write. 283 * @param start An integer array of dimension rank which holds the 284 * startcoordinates of the data subset in the larger dataset. 285 * @param size An integer array of dimension rank whidh holds the 286 * size in each dimension of the data subset to write. 287 * @exception NexusException when an HDF error occurs. 288 */ 289 public void putslab(Object array, long start[], long size[]) throws 290 NexusException; 291 231 292 /** 232 293 * putattr adds a named attribute to a previously opened dataset or … … 250 311 * @exception NexusException when an HDF error occurs. 251 312 */ 252 public void getinfo(int iDim[], int args[]) throws 253 NexusException; 313 public void getinfo(int iDim[], int args[]) throws NexusException; 314 315 /** 316 * getinfo retrieves information about a previously opened dataset. 317 * @param iDim An array which will be filled with the size of 318 * the dataset in each dimension. 319 * @param args An integer array which will hold more information about 320 * the dataset after return. The fields: args[0] is the rank, args[1] is 321 * the number type. 322 * @exception NexusException when an HDF error occurs. 323 */ 324 public void getinfo(long iDim[], int args[]) throws NexusException; 325 254 326 /** 255 327 * setnumberformat sets the number format for printing number when … … 261 333 * @param format The new format to use. 262 334 */ 263 public void setnumberformat(int type, String format) 264 throws NexusException; 335 public void setnumberformat(int type, String format) throws NexusException; 336 265 337 /** 266 338 * groupdir will retrieve the content of the currently open vGroup. … … 271 343 * @exception NexusException if an HDF error occurs 272 344 */ 273 public Hashtable groupdir() throws274 NexusException; 345 public Hashtable groupdir() throws NexusException; 346 275 347 /** 276 348 * attrdir returns the attributes of the currently open dataset or … … 280 352 * @exception NexusException when an HDF error occurs. 281 353 */ 282 public Hashtable attrdir()throws 283 NexusException; 354 public Hashtable attrdir() throws NexusException; 284 355 285 356 // linking … … 290 361 * @exception NexusException if an HDF error occurs. 291 362 */ 292 public NXlink getgroupID() throws 293 NexusException; 363 public NXlink getgroupID() throws NexusException; 364 294 365 /** 295 366 * getdataID gets the data necessary for linking the current dataset … … 298 369 * @exception NexusException if an HDF error occurs. 299 370 */ 300 public NXlink getdataID()throws 301 NexusException; 371 public NXlink getdataID()throws NexusException; 372 302 373 /** 303 374 * makelink links the object described by target into the current … … 306 377 * @exception NexusException if an error occurs. 307 378 */ 308 public void makelink(NXlink target)throws 309 NexusException; 379 public void makelink(NXlink target)throws NexusException; 310 380 /** 311 381 * makenamedlink links the object described by target into the current … … 316 386 * @exception NexusException if an error occurs. 317 387 */ 318 public void makenamedlink(String name, NXlink target)throws319 NexusException; 388 public void makenamedlink(String name, NXlink target) throws NexusException; 389 320 390 /** 321 391 * opensourcepath opens the group from which the current item was linked … … 323 393 * @exception NexusException if an error occurs. 324 394 */ 325 public void opensourcepath()throws326 NexusException; 395 public void opensourcepath() throws NexusException; 396 327 397 /** 328 398 * inquirefile inquires which file we are currently in. This is … … 332 402 */ 333 403 public String inquirefile() throws NexusException; 404 334 405 /** 335 406 * linkexternal links group name, nxclass to the URL nxurl … … 340 411 */ 341 412 public void linkexternal(String name, String nxclass, String nxurl) throws NexusException; 342 /** 343 * nxisexternalgroup test the group name, nxclass if it is linked externally. 413 414 /** 415 * linkexternaldataset links dataset name to the URL nxurl 416 * @param name The name of the dataset to link to 417 * @param nxurl The URL to the linked external file 418 * @throws NexusException if things are wrong 419 */ 420 public void linkexternaldataset(String name, String nxurl) throws NexusException; 421 422 /** 423 * nxisexternalgroup test the group name, nxclass if it is linked externally 344 424 * @param name of the group to test 345 425 * @param nxclass class of the group to test 346 426 * @return null when the group is not linked, else a string giving the URL of the 347 * linked file.427 * linked resource 348 428 * @throws NexusException if things are wrong 349 429 */ 350 430 public String isexternalgroup(String name, String nxclass) throws NexusException; 431 432 /** 433 * nxisexternaldataset if the named dataset is is linked externally 434 * @param name of the dataset to test 435 * @return null when the it is not linked, else a string giving the URL of the 436 * linked resource 437 * @throws NexusException if things are wrong 438 */ 439 public String isexternaldataset(String name) throws NexusException; 351 440 } 352 -
trunk/bindings/java/org/nexusformat/NexusFile.java
r1486 r1734 1 1 /** 2 * 3 * @mainpage The NeXus-API for Java. 4 * NeXus is an attempt to define a common data 5 * format for org and x-ray diffraction. NeXus is built on top of the 6 * Hierarchical Data Format from NCSA. There exist already API's to 7 * NeXus files for F77, F90, C and C++. This is an implementation of 2 * @mainpage This is an implementation of 8 3 * a Java NeXus API using native methods. 9 4 * 10 * Some changes to the API have been necessary however, due to the5 * Some changes to the API have been necessary, due to the 11 6 * different calling standards between C and Java. 12 7 * 13 * 14 * @author Mark Koennecke, October 2000 15 * 16 * Updated: Mark Koennecke, April 2006 8 * @author Mark Koennecke, 2000 -- 2011 17 9 * 18 10 * copyright: see accompanying COPYRIGHT file 19 11 * 20 * added nxinitattrdir: Mark Koennecke, October 200921 *22 12 * @see TestJapi.java 23 *24 */25 26 /**27 * @example TestJapi.java28 13 * Test program for Java API. 29 14 * Illustrates using the #org.nexusformat package … … 37 22 import ncsa.hdf.hdflib.HDFConstants; 38 23 39 public class NexusFile implements NeXusFileInterface {24 public class NexusFile implements NeXusFileInterface { 40 25 41 26 // constants … … 143 128 * an HDF error occurred. 144 129 */ 145 public NexusFile(String filename, int access) throws NexusException 146 { 147 checkForNull(filename); 130 public NexusFile(String filename, int access) throws NexusException { 131 checkForNull(filename); 148 132 149 133 handle = init(filename,access); … … 152 136 } 153 137 } 138 154 139 /** 155 140 * flushes all pending data to disk. Closes any open SDS's. 156 141 */ 157 public void flush() throws NexusException 158 { 142 public void flush() throws NexusException { 159 143 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 160 144 handle = nxflush(handle); 161 145 } 146 162 147 /** 163 148 * close the NeXus file. To make javalint and diamond happy 164 149 * @throws NexusException 165 150 */ 166 public void close() throws NexusException{ 167 if(handle >= 0) 168 { 151 public void close() throws NexusException { 152 if(handle >= 0) { 169 153 close(handle); 170 154 handle = -1; … … 182 166 * do any harm. 183 167 */ 184 public void finalize() throws Throwable 185 { 168 public void finalize() throws Throwable { 186 169 close(); 187 170 } … … 197 180 protected native String nxgetpath(int handle); 198 181 199 /** 200 * makegroup creates a new group below the current group within 201 * the NeXus file hierarchy. 202 * @param name The name of the group to create. 203 * @param nxclass The classname of the group. 204 * @exception NexusException if an error occurs during this operation. 205 */ 206 public void makegroup(String name, String nxclass) throws 207 NexusException 208 { 182 public void makegroup(String name, String nxclass) throws NexusException { 209 183 checkForNull(name, nxclass); 210 184 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 211 185 nxmakegroup(handle, name, nxclass); 212 186 } 213 /** 214 * opengroup opens the group name with class nxclass. 215 * The group must exist, otherwise an exception is thrown. opengroup is 216 * similar to a cd name in a filesystem. 217 * @param name the name of the group to open. 218 * @param nxclass the classname of the group to open. 219 * @exception NexusException when something goes wrong. 220 */ 221 public void opengroup(String name, String nxclass) throws 222 NexusException 223 { 187 188 public void opengroup(String name, String nxclass) throws NexusException { 224 189 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 225 190 checkForNull(name, nxclass); 226 191 nxopengroup(handle, name, nxclass); 227 192 } 228 /** 229 * openpath opens groups and datsets accroding to the path string 230 * given. The path syntax follows unix conventions. Both absolute 231 * and relative paths are possible. All objects of the path must 232 * exist. 233 * @param path The path string 234 * @exception NexusException when something goes wrong. 235 */ 236 public void openpath(String path) throws 237 NexusException 238 { 193 194 public void openpath(String path) throws NexusException { 239 195 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 240 196 checkForNull(path); 241 197 nxopenpath(handle,path); 242 198 } 243 /** 244 * opengrouppath opens groups and datsets accroding to the path string 245 * given. The path syntax follows unix conventions. Both absolute 246 * and relative paths are possible. All objects of the path must 247 * exist. This opens only until the last group. 248 * @param path The path string 249 * @exception NexusException when something goes wrong. 250 */ 251 public void opengrouppath(String path) throws 252 NexusException 253 { 199 200 public void opengrouppath(String path) throws NexusException { 254 201 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 255 202 checkForNull(path); 256 203 nxopengrouppath(handle,path); 257 204 } 258 /** 259 * return the current path into the NeXus file in the 260 * form of a Unix path string. 261 * @return A unix path string 262 */ 263 public String getpath() throws NexusException 264 { 205 206 public String getpath() throws NexusException { 265 207 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 266 208 return nxgetpath(handle); 267 209 } 268 /** 269 * closegroup closes access to the current group and steps down one 270 * step in group hierarchy. 271 * @exception NexusException when an HDF error occurs during this 272 * operation. 273 */ 274 public void closegroup() throws 275 NexusException 276 { 210 211 public void closegroup() throws NexusException { 277 212 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 278 213 nxclosegroup(handle); … … 281 216 // data set handling 282 217 // native methods for this section 283 protected native void nxmakedata(int handle, String name, int type, 284 int rank, int dim[]); 285 protected native void nxmakecompdata(int handle, String name, int type, 286 int rank, int dim[], int iCompress, 287 int iChunk[]); 218 protected native void nxmakedata(int handle, String name, int type, int rank, int dim[]); 219 protected native void nxmakedata64(int handle, String name, int type, int rank, long dim[]); 220 protected native void nxmakecompdata(int handle, String name, int type, int rank, int dim[], int iCompress, int iChunk[]); 221 protected native void nxmakecompdata64(int handle, String name, int type, int rank, long dim[], int iCompress, long iChunk[]); 288 222 protected native void nxopendata(int handle, String name); 289 223 protected native void nxclosedata(int handle); 290 224 protected native void nxcompress(int handle, int compression_type); 291 /** 292 * compmakedata creates a new dataset with the specified characteristics 293 * in the current group. This data set will be compressed. 294 * @param name The name of the dataset. 295 * @param type The number type of the dataset. Usually a constant from 296 * a selection of values. 297 * @param rank The rank or number of dimensions of the dataset. 298 * @param dim An array containing the length of each dimension. dim must 299 * have at least rank entries. The first dimension can be -1 which 300 * means it is an unlimited dimension. 301 * @param compression_type determines the compression type. 302 * @param iChunk With HDF-5, slabs can be written to compressed data 303 * sets. The size of these slabs is specified through the chunk array. 304 * This must have the rank values for the size of the chunk to 305 * be written in each dimension. 306 * @exception NexusException when the dataset could not be created. 307 */ 225 308 226 public void compmakedata(String name, int type, int rank, int dim[], 309 int compression_type, int iChunk[]) throws 310 NexusException { 311 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 227 int compression_type, int iChunk[]) throws NexusException { 228 if (handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 312 229 checkType(type); 313 230 checkForNull(name, rank, iChunk); 314 checkForNegIn IntArray(true, dim, iChunk);231 checkForNegInArray(true, dim, iChunk); 315 232 switch(compression_type) { 316 233 case NexusFile.NX_COMP_NONE: … … 324 241 } 325 242 326 /** 327 * makedata creates a new dataset with the specified characteristics 328 * in the current group. 329 * @param name The name of the dataset. 330 * @param type The number type of the dataset. Usually a constant from 331 * a selection of values. 332 * @param rank The rank or number of dimensions of the dataset. 333 * @param dim An array containing the length of each dimension. dim must 334 * have at least rank entries. The first dimension can be -1 which 335 * means it is an unlimited dimension. 336 * @exception NexusException when the dataset could not be created. 337 */ 243 public void compmakedata(String name, int type, int rank, long dim[], 244 int compression_type, long iChunk[]) throws NexusException { 245 if (handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 246 checkType(type); 247 checkForNull(name, rank, iChunk); 248 checkForNegInArray(true, dim, iChunk); 249 switch(compression_type) { 250 case NexusFile.NX_COMP_NONE: 251 case NexusFile.NX_COMP_LZW: 252 break; 253 default: 254 throw new NexusException("Invalid compression code requested"); 255 256 } 257 nxmakecompdata64(handle, name, type, rank, dim, compression_type, iChunk); 258 } 259 338 260 public void makedata(String name, int type, int rank, int dim[]) throws 339 NexusException 340 { 261 NexusException { 341 262 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 342 263 checkType(type); 343 264 checkForNull(name, dim); 344 checkForNegIn IntArray(true, dim);265 checkForNegInArray(true, dim); 345 266 nxmakedata(handle, name, type, rank, dim); 346 267 } 347 /** 348 * opendata opens an existing dataset for access. For instance for 349 * reading or writing. 350 * @param name The name of the dataset to open. 351 * @exception NexusException when the dataset does not exist or 352 * something else is wrong. 353 */ 354 public void opendata(String name)throws 355 NexusException 356 { 268 269 public void makedata(String name, int type, int rank, long dim[]) throws 270 NexusException { 271 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 272 checkType(type); 273 checkForNull(name, dim); 274 checkForNegInArray(true, dim); 275 nxmakedata64(handle, name, type, rank, dim); 276 } 277 278 public void opendata(String name) throws NexusException { 357 279 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 358 280 checkForNull(name); 359 281 nxopendata(handle,name); 360 282 } 361 /** 362 * closedata closes an opened dataset. Then no further access is 363 * possible without a call to opendata. 364 * @exception NexusException when an HDF error occurrs. 365 */ 366 public void closedata() throws 367 NexusException 368 { 283 284 public void closedata() throws NexusException { 369 285 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 370 286 nxclosedata(handle); 371 287 } 372 /** 373 * causes the currently open dataset to be compressed on file. 374 * This must be called after makedata and before writing to the 375 * dataset. 376 * @param compression_type determines the type of compression 377 * to use. 378 * @exception NexusException when no dataset is open or an HDF error 379 * occurs. 380 */ 381 public void compress(int compression_type) throws 382 NexusException 383 { 288 289 public void compress(int compression_type) throws NexusException { 384 290 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 385 291 switch(compression_type) { … … 399 305 // native methods in this section 400 306 protected native void nxgetdata(int handle, byte bdata[]); 401 protected native void nxgetslab(int handle, int Start[], int size[], 402 byte bdata[]); 403 protected native void nxgetattr(int handle, String name, byte bdata[], 404 int args[]); 405 /** 406 * getdata reads the data from an previously openend dataset into 407 * array. 408 * @param array An n-dimensional array of the appropriate number 409 * type for the dataset. Make sure to have the right type and size 410 * here. 411 * @exception NexusException when either an HDF error occurs or 412 * no dataset is open or array is not of the right type to hold 413 * the data. 414 */ 415 public void getdata(Object array)throws 416 NexusException 417 { 307 protected native void nxgetslab(int handle, int Start[], int size[], byte bdata[]); 308 protected native void nxgetslab64(int handle, long Start[], long size[], byte bdata[]); 309 protected native void nxgetattr(int handle, String name, byte bdata[], int args[]); 310 311 public void getdata(Object array) throws NexusException { 418 312 byte bdata[]; 419 313 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); … … 428 322 } 429 323 } 430 /** 431 * getslab reads a subset of a large dataset into array. 432 * @param start An array of dimension rank which contains the start 433 * position in the dataset from where to start reading. 434 * @param size An array of dimension rank which contains the size 435 * of the dataset subset in each dimension to read. 436 * @param array An array for holding the returned data values. 437 * @exception NexusException when either an HDF error occurs or 438 * no dataset is open or array is not of the right type to hold 439 * the data. 440 */ 441 public void getslab(int start[], int size[],Object array)throws 442 NexusException 443 { 324 325 public void getslab(int start[], int size[], Object array) throws NexusException { 444 326 byte bdata[]; 445 327 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 446 328 checkForNull(start, size, array); 447 checkForNegIn IntArray(false, start, size);329 checkForNegInArray(false, start, size); 448 330 try{ 449 331 HDFArray ha = new HDFArray(array); … … 455 337 } 456 338 } 457 /** 458 * getattr retrieves the data associated with the attribute 459 * name. 460 * @param name The name of the attribute. 461 * @param array an array with sufficient space for holding the attribute 462 * data. 463 * @param args An integer array of dimension rank which holds the 464 * length of the array as first value and the type as the last 465 * value. Both values will be updated during reading. 466 * @exception NexusException when either an HDF error occurs or 467 * the attribute could not be found. 468 */ 469 public void getattr(String name, Object array, int args[])throws 470 NexusException 471 { 339 340 public void getslab(long start[], long size[], Object array) throws NexusException { 341 byte bdata[]; 342 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 343 checkForNull(start, size, array); 344 checkForNegInArray(false, start, size); 345 try{ 346 HDFArray ha = new HDFArray(array); 347 bdata = ha.emptyBytes(); 348 nxgetslab64(handle,start,size,bdata); 349 array = ha.arrayify(bdata); 350 }catch(HDFException he) { 351 throw new NexusException(he.getMessage()); 352 } 353 } 354 355 public void getattr(String name, Object array, int args[]) throws NexusException { 472 356 byte bdata[]; 473 357 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); … … 487 371 // native methods for this section 488 372 protected native void nxputdata(int handle, byte array[]); 489 protected native void nxputslab(int handle, byte array[], 490 int start[],int size[]); 491 protected native void nxputattr(int handle, String name, 492 byte array[], int type); 493 494 /** 495 * putdata writes the data from array into a previously opened 496 * dataset. 497 * @param array The data to write. 498 * @exception NexusException when an HDF error occurs. 499 */ 500 public void putdata(Object array) throws 501 NexusException 502 { 373 protected native void nxputslab(int handle, byte array[], int start[], int size[]); 374 protected native void nxputslab64(int handle, byte array[], long start[], long size[]); 375 protected native void nxputattr(int handle, String name, byte array[], int type); 376 377 public void putdata(Object array) throws NexusException { 503 378 byte data[]; 504 379 … … 506 381 checkForNull(array); 507 382 508 try {383 try { 509 384 HDFArray ha = new HDFArray(array); 510 385 data = ha.byteify(); 511 386 ha = null; 512 } catch(HDFException he) {387 } catch (HDFException he) { 513 388 throw new NexusException(he.getMessage()); 514 389 } … … 516 391 data = null; 517 392 } 518 /** 519 * putslab writes a subset of a larger dataset to a previously opened 520 * dataset. 521 * @param array The data to write. 522 * @param start An integer array of dimension rank which holds the 523 * startcoordinates of the data subset in the larger dataset. 524 * @param size An integer array of dimension rank which holds the 525 * size in each dimension of the data subset to write. 526 * @exception NexusException when an HDF error occurs. 527 */ 528 public void putslab(Object array, int start[], int size[]) throws 529 NexusException 530 { 393 394 public void putslab(Object array, int start[], int size[]) throws NexusException { 531 395 byte data[]; 532 396 533 397 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 534 398 checkForNull(array, start, size); 535 checkForNegIn IntArray(false, start,size);536 try {399 checkForNegInArray(false, start, size); 400 try { 537 401 HDFArray ha = new HDFArray(array); 538 402 data = ha.byteify(); 539 403 ha = null; 540 } catch(HDFException he) {404 } catch(HDFException he) { 541 405 throw new NexusException(he.getMessage()); 542 406 } … … 544 408 data = null; 545 409 } 546 /** 547 * putattr adds a named attribute to a previously opened dataset or 548 * a global attribute if no dataset is open. 549 * @param name The name of the attribute. 550 * @param array The data of the attribute. 551 * @param iType The number type of the attribute. 552 * @exception NexusException if an HDF error occurs. 553 */ 554 public void putattr(String name, Object array, int iType) throws 555 NexusException 556 { 410 411 public void putslab(Object array, long start[], long size[]) throws NexusException { 412 byte data[]; 413 414 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 415 checkForNull(array, start, size); 416 checkForNegInArray(false, start, size); 417 try { 418 HDFArray ha = new HDFArray(array); 419 data = ha.byteify(); 420 ha = null; 421 } catch(HDFException he) { 422 throw new NexusException(he.getMessage()); 423 } 424 nxputslab64(handle,data,start,size); 425 data = null; 426 } 427 428 public void putattr(String name, Object array, int iType) throws NexusException { 557 429 byte data[]; 558 430 … … 574 446 //native methods for this section 575 447 protected native void nxgetinfo(int handle, int iDim[], int args[]); 448 protected native void nxgetinfo64(int handle, long iDim[], int args[]); 576 449 protected native void nxsetnumberformat(int handle, int type, 577 450 String format); … … 580 453 protected native void initattrdir(int handle); 581 454 protected native void initgroupdir(int handle); 582 /** 583 * setnumberformat sets the number format for printing number when 584 * using the XML-NeXus format. For HDF4 and HDF5 this is ignored. 585 * If a dataset is open, the format for the dataset is set, if none 586 * is open the default setting for the number type is changed. 587 * The format must be a ANSII-C language format string. 588 * @param type The NeXus type to set the format for. 589 * @param format The new format to use. 590 */ 591 public void setnumberformat(int type, String format) 592 throws NexusException{ 455 456 public void setnumberformat(int type, String format) throws NexusException { 593 457 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 594 458 checkType(type); … … 596 460 nxsetnumberformat(handle,type,format); 597 461 } 598 /** 599 * getinfo retrieves information about a previously opened dataset. 600 * @param iDim An array which will be filled with the size of 601 * the dataset in each dimension. 602 * @param args An integer array which will hold more information about 603 * the dataset after return. The fields: args[0] is the rank, args[1] is 604 * the number type. 605 * @exception NexusException when an HDF error occurs. 606 */ 607 public void getinfo(int iDim[], int args[]) throws 608 NexusException 609 { 462 463 public void getinfo(int iDim[], int args[]) throws NexusException { 610 464 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 611 465 nxgetinfo(handle,iDim,args); 612 466 } 613 /** 614 * groupdir will retrieve the content of the currently open vGroup. 615 * groupdir is similar to an ls in unix. 616 * @return A Hashtable which will hold the names of the items in 617 * the group as keys and the NeXus classname for vGroups or the 618 * string 'SDS' for datasets as values. 619 * @exception NexusException if an HDF error occurs 620 */ 621 public Hashtable groupdir()throws 622 NexusException 623 { 467 468 public void getinfo(long iDim[], int args[]) throws NexusException { 469 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 470 nxgetinfo64(handle,iDim,args); 471 } 472 473 public Hashtable groupdir() throws NexusException { 624 474 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 625 475 Hashtable h = new Hashtable(); 626 476 String names[] = new String[2]; 627 int i;628 477 629 478 initgroupdir(handle); 630 while(nextentry(handle,names) != -1) 631 { 479 while(nextentry(handle,names) != -1) { 632 480 h.put(names[0],names[1]); 633 481 } 634 482 return h; 635 483 } 636 /** 637 * attrdir returns the attributes of the currently open dataset or 638 * the file global attributes if no dataset is open. 639 * @return A Hashtable which will hold the names of the attributes 640 * as keys. For each key there is an AttributeEntry class as value. 641 * @exception NexusException when an HDF error occurs. 642 */ 643 public Hashtable attrdir()throws 644 NexusException 645 { 484 485 public Hashtable attrdir()throws NexusException { 646 486 int args[] = new int[2]; 647 487 AttributeEntry at; … … 668 508 protected native void nxmakenamedlink(int handle, String name, NXlink target); 669 509 protected native void nxopensourcepath(int handle); 670 /** 671 * getgroupID gets the data necessary for linking the current vGroup 672 * somewhere else. 673 * @return A NXlink class holding the link data. 674 * @exception NexusException if an HDF error occurs. 675 */ 676 public NXlink getgroupID() throws 677 NexusException 678 { 510 511 public NXlink getgroupID() throws NexusException { 679 512 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 680 513 NXlink l = new NXlink(); … … 682 515 return l; 683 516 } 684 /** 685 * getdataID gets the data necessary for linking the current dataset 686 * somewhere else. 687 * @return A NXlink class holding the link data. 688 * @exception NexusException if an HDF error occurs. 689 */ 690 public NXlink getdataID()throws 691 NexusException 692 { 517 518 public NXlink getdataID()throws NexusException { 693 519 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 694 520 NXlink l = new NXlink(); … … 696 522 return l; 697 523 } 698 /** 699 * makelink links the object described by target into the current 700 * vGroup. 701 * @param target The Object to link into the current group. 702 * @exception NexusException if an error occurs. 703 */ 704 public void makelink(NXlink target)throws 705 NexusException 706 { 524 525 public void makelink(NXlink target) throws NexusException { 707 526 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 708 527 checkForNull(target); 709 528 nxmakelink(handle, target); 710 529 } 711 /** 712 * makenamedlink links the object described by target into the current 713 * vGroup. The object will have a new name in the group into which it is 714 * linked 715 * @param target The Object to link into the current group. 716 * @param name The name of this object in the current group 717 * @exception NexusException if an error occurs. 718 */ 719 public void makenamedlink(String name, NXlink target)throws 720 NexusException { 530 531 public void makenamedlink(String name, NXlink target) throws NexusException { 721 532 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 722 533 checkForNull(name, target); … … 724 535 } 725 536 726 /** 727 * opensourcepath opens the group from which the current item was linked 728 * Returns an error if the current item is not linked. 729 * @exception NexusException if an error occurs. 730 */ 731 public void opensourcepath()throws 732 NexusException 733 { 537 public void opensourcepath() throws NexusException { 734 538 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 735 539 nxopensourcepath(handle); … … 748 552 * checks if any of the ints in the arrays are negative, 749 553 * throws appropriate runtime exception if so 750 * for some being zero is stupid, but hopefully not fatal751 554 */ 752 private void checkForNegInIntArray(boolean allowUnlimited, int[]... args) { 753 boolean first=true; 555 private void checkForNegInArray(boolean allowUnlimited, int[]... args) { 754 556 for (int[] array : args) 755 557 for (int value: array) { 756 558 if (value<0) 757 if (value == this.NX_UNLIMITED && allowUnlimited && first) {559 if (value == this.NX_UNLIMITED && allowUnlimited) { 758 560 // all ok this time 759 561 } else 760 562 throw new IllegalArgumentException("negative dimension received"); 761 first=false;762 563 } 763 564 } 565 566 /** 567 * checks if any of the longs in the arrays are negative, 568 * throws appropriate runtime exception if so 569 */ 570 private void checkForNegInArray(boolean allowUnlimited, long[]... args) { 571 for (long[] array : args) 572 for (long value: array) { 573 if (value<0) 574 if (value == this.NX_UNLIMITED && allowUnlimited) { 575 // all ok this time 576 } else 577 throw new IllegalArgumentException("negative dimension received"); 578 } 579 } 580 764 581 /** 765 582 * checkType verifies if a parameter is a valid NeXus type code. … … 768 585 * @exception NexusException if the the type is no known type value 769 586 */ 770 private void checkType(int type) throws NexusException 771 { 587 private void checkType(int type) throws NexusException { 772 588 switch(type) { 773 589 case NexusFile.NX_FLOAT32: … … 792 608 protected native void nxinquirefile(int handle, String names[]); 793 609 protected native void nxlinkexternal(int handle, String name, String nxclass, String nxurl); 610 protected native void nxlinkexternaldataset(int handle, String name, String nxurl); 794 611 protected native int nxisexternalgroup(int handle, String name, String nxclass, String nxurl[]); 795 /** 796 * inquirefile inquires which file we are currently in. This is 797 * a support function for external linking 798 * @return The current file 799 * @throws NexusException when things are wrong 800 */ 612 protected native int nxisexternaldataset(int handle, String name, String nxurl[]); 613 801 614 public String inquirefile() throws NexusException { 802 615 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); … … 805 618 return names[0]; 806 619 } 807 /** 808 * linkexternal links group name, nxclass to the URL nxurl 809 * @param name The name of the vgroup to link to 810 * @param nxclass The class name of the linked vgroup 811 * @param nxurl The URL to the linked external file 812 * @throws NexusException if things are wrong 813 */ 814 public void linkexternal(String name, String nxclass, String nxurl) throws NexusException{ 620 621 public void linkexternal(String name, String nxclass, String nxurl) throws NexusException { 815 622 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 816 623 checkForNull(name, nxclass, nxurl); 817 624 nxlinkexternal(handle,name,nxclass,nxurl); 818 625 } 819 /** 820 * nxisexternalgroup test the group name, nxclass if it is linked externally. 821 * @param name of the group to test 822 * @param nxclass class of the group to test 823 * @return null when the group is not linked, else a string giving the URL of the 824 * linked file. 825 * @throws NexusException if things are wrong 826 */ 827 public String isexternalgroup(String name, String nxclass) throws NexusException{ 828 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 626 627 public void linkexternaldataset(String name, String nxurl) throws NexusException { 628 if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 629 checkForNull(name, nxurl); 630 nxlinkexternaldataset(handle,name,nxurl); 631 } 632 633 public String isexternalgroup(String name, String nxclass) throws NexusException { 634 if (handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 829 635 checkForNull(name, nxclass); 830 636 String nxurl[] = new String[1]; 831 637 832 638 int status = nxisexternalgroup(handle,name,nxclass,nxurl); 833 if(status == 1){ 639 if (status == 1) { 640 return nxurl[0]; 641 } else { 642 return null; 643 } 644 } 645 646 public String isexternaldataset(String name) throws NexusException { 647 if (handle < 0) throw new NexusException("NAPI-ERROR: File not open"); 648 checkForNull(name); 649 String nxurl[] = new String[1]; 650 651 int status = nxisexternaldataset(handle,name,nxurl); 652 if (status == 1) { 834 653 return nxurl[0]; 835 654 } else { -
trunk/include/napi.h
r1731 r1734 26 26 ----------------------------------------------------------------------------*/ 27 27 /** \file 28 * Documentation for the NeXus-API version 4. 229 * 2000-20 07, the NeXus group28 * Documentation for the NeXus-API version 4.3 29 * 2000-2011, the NeXus International Advisory Commitee 30 30 * \defgroup c_main C API 31 31 * \defgroup c_types Data Types
Note: See TracChangeset
for help on using the changeset viewer.
