Java Code Examples for org.apache.commons.lang3.ArrayUtils.toObject()

The following are Jave code examples for showing how to use toObject() of the org.apache.commons.lang3.ArrayUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: URTorrent   File: BencodeReader.java   View Source Code Vote up 6 votes
/**
 * Reads a bencoded <code>String</code> from the <code>InputStream</code>.
 *
 * @since 0.1.0
 * @exception IOException if an IO exception occurs when reading
 * @exception EOFException if the stream ended unexpectedly
 * @exception BencodeReadException if the value read is not a properly bencoded String
 */
public Byte[] readString() throws IOException, BencodeReadException {
    int len = readLen();
    // now read until we have the entire thing
    byte[] bs = new byte[len];
    if (len == 0) { // edge case where last value is an empty string
        return new Byte[0];
    }
    int off = input.read(bs);
    if (off == -1) {
        throw new EOFException();
    }
    while (off != len) {
        int more = input.read(bs, off, len - off);
        if (more == -1) {
            throw new EOFException();
        }
        off += more;
    }
   
		
    return ArrayUtils.toObject(bs);
}
 
Example 2
Project: Cognizant-Intelligent-Test-Scripter   File: JtableUtils.java   View Source Code Vote up 6 votes
/**
 * deletes all selected columns if it is not present in the <code>exp</code>
 * List
 *
 * @param table the table to DELETE columns
 * @param exp columns to avoid deleting
 * @see #deletecol(javax.swing.JTable, int)
 */
static void deletecols(JTable table, int[] exp) {
    Integer[] selcols;
    try {
        TableColumnModel tcm = table.getColumnModel();
        selcols = ArrayUtils.toObject(table.getSelectedColumns());
        Arrays.sort(selcols, Collections.reverseOrder());
        List<Integer> explist = Ints.asList(exp);
        for (int i : selcols) {
            if (!explist.contains(i)) {
                tcm.removeColumn(tcm.getColumn(i));
            }
        }

    } catch (Exception e) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, e);
    }

}
 
Example 3
Project: sumo   File: AlosGeoTiff.java   View Source Code Vote up 5 votes
@Override
public void preloadLineTile(int y, int length, int band) {
	if (y < 0) {
           return;
       }
       preloadedInterval = new int[]{y, y + length};
       Rectangle rect = new Rectangle(0, y, getImage(band).xSize, length);

       TIFF tiff=getImage(band);
       rect=tiff.getBounds().intersection(rect);
       try {
       	BufferedImage bi=null;
       	try{
       			bi=tiff.read(0, rect);
       	}catch(Exception e){
       		logger.warn("Problem reading image POS x:"+0+ "  y: "+y +"   try to read again");
       		try {
   			    Thread.sleep(100);
   			} catch(InterruptedException exx) {
   			    Thread.currentThread().interrupt();
   			}
       		bi=tiff.read(0, rect);
       	}
       	WritableRaster raster=bi.getRaster();
       	short[]ss=(short[])raster.getDataElements(0, 0, raster.getWidth(), raster.getHeight(), null);//tSamples(0, 0, raster.getWidth(), raster.getHeight(), 0, (short[]) null);
       	preloadedData=ArrayUtils.toObject(ss);
       } catch (Exception ex) {
           logger.error(ex.getMessage(),ex);
       }finally{
       	//tiff.reader.addIIOReadProgressListener(this);
       	//readComplete=false;

       }

}
 
Example 4
Project: sumo   File: GDALAlosCeos.java   View Source Code Vote up 5 votes
@Override
public void preloadLineTile(int y, int length, int band) {
	if (y < 0) {
		return;
	}
	GeoToolsGDALReader tiff = (GeoToolsGDALReader)getImage(band);

	preloadedInterval = new int[] { y, y + length };
	Rectangle rect = new Rectangle(0, y, tiff.getxSize(), length);

	rect = tiff.getBounds().intersection(rect);

	try {
		int[] bi = null;
		try {
			bi = tiff.readPixValues(0, y, rect.width, rect.height);
			//bi = tiff.readShortValues(0, y, tiff.xSize, length);
		} catch (Exception e) {
			logger.warn("Problem reading image POS x:" + 0 + "  y: " + y + "   try to read again");
			try {
				Thread.sleep(100);
			} catch (InterruptedException exx) {
				Thread.currentThread().interrupt();
			}
			bi = tiff.readPixValues(0, y, rect.width, rect.height);
		}
		preloadedData =ArrayUtils.toObject(bi);
	} catch (Exception ex) {
		logger.error(ex.getMessage(), ex);
	} finally {

	}

}
 
Example 5
Project: sumo   File: BinaryAlosCeos.java   View Source Code Vote up 5 votes
@Override
public void preloadLineTile(int y, int length, int band) {
	if (y < 0) {
		return;
	}
	CeosBinaryReader tiff = (CeosBinaryReader)getImage(band);

	preloadedInterval = new int[] { y, y + length };
	Rectangle rect = new Rectangle(0, y, tiff.getxSize(), length);

	rect = tiff.getBounds().intersection(rect);

	try {
		int[] bi = null;
		try {
			bi = tiff.readInt(0, y, rect.width, rect.height);
			//bi = tiff.readShortValues(0, y, tiff.xSize, length);
		} catch (Exception e) {
			logger.warn("Problem reading image POS x:" + 0 + "  y: " + y + "   try to read again");
			try {
				Thread.sleep(100);
			} catch (InterruptedException exx) {
				Thread.currentThread().interrupt();
			}
			bi = tiff.readInt(0, y, rect.width, rect.height);
		}
		preloadedData = ArrayUtils.toObject(bi);
	} catch (Exception ex) {
		logger.error(ex.getMessage(), ex);
	} finally {

	}

}
 
Example 6
Project: java-bean-validation-extension   File: OneOfCharsValidator.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(Character value, ConstraintValidatorContext context) {
    return super.isValid(value, ArrayUtils.toObject(annotation.value()), Objects::equals, context);
}
 
Example 7
Project: java-bean-validation-extension   File: OneOfDoublesValidator.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(Double value, ConstraintValidatorContext context) {
    return super.isValid(value, ArrayUtils.toObject(annotation.value()), Objects::equals, context);
}
 
Example 8
Project: java-bean-validation-extension   File: OneOfIntegersValidator.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
    return super.isValid(value, ArrayUtils.toObject(annotation.value()), Objects::equals, context);
}
 
Example 9
Project: java-bean-validation-extension   File: OneOfLongsValidator.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(Long value, ConstraintValidatorContext context) {
    return super.isValid(value, ArrayUtils.toObject(annotation.value()), Objects::equals, context);
}