类org.apache.commons.io.EndianUtils源码实例Demo

下面列出了怎么用org.apache.commons.io.EndianUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: riiablo   文件: DS1.java
private void readObjects(InputStream in) throws IOException {
  final int MAX_X = width  * DT1.Tile.SUBTILE_SIZE;
  final int MAX_Y = height * DT1.Tile.SUBTILE_SIZE;
  numObjects = version < 2 ? 0 : EndianUtils.readSwappedInteger(in);
  objects = numObjects == 0 ? Object.EMPTY_OBJECT_ARRAY : new Object[numObjects];
  for (int i = 0; i < numObjects; i++) {
    try {
      Object object = objects[i] = new Object().read(version, in);
      if (DEBUG_OBJECTS) Gdx.app.debug(TAG, object.toString());
      if (object.x < 0 || MAX_X <= object.x
       || object.y < 0 || MAX_Y <= object.y) {
        Gdx.app.error(TAG, "Object out of DS1 bounds: " + object);
      }
    } catch (Throwable t) {
      // Don't care, invalid object, skip it. Log it for posterity.
      Gdx.app.error(TAG, t.getMessage(), t);
    }
  }
}
 
源代码2 项目: FoxTelem   文件: AirspyDevice.java
/**
 * Queries the device for available sample rates.  Will always provide at
 * least the default 10 MHz sample rate.
 */
private void determineAvailableSampleRates() 
					throws LibUsbException, DeviceException
{
	mSampleRates.clear();
	
	mSampleRates.add( DEFAULT_SAMPLE_RATE );
	
	//Get a count of available sample rates.  If we get an exception, then
	//we're using an older firmware revision and only the default 10 MHz
	//rate is supported
	try
	{
		byte[] rawCount = readArray( Command.GET_SAMPLE_RATES, 0, 0, 4 );

		
		if( rawCount != null )
		{
			int count = EndianUtils.readSwappedInteger( rawCount, 0 );
			
			byte[] rawRates = readArray( Command.GET_SAMPLE_RATES, 0, 
					count, ( count * 4 ) );

			for( int x = 0; x < count; x++ )
			{
				int rate = EndianUtils.readSwappedInteger( rawRates, ( x * 4 ) );
				
				if( rate != DEFAULT_SAMPLE_RATE.getRate() )
				{
					mSampleRates.add( new AirspySampleRate( x, rate, 
							formatSampleRate( rate ) ) );
				}
			}
		}
	}
	catch( LibUsbException e )
	{
		//Press on, nothing else to do here ..
	}
}
 
源代码3 项目: riiablo   文件: DS1.java
private int readTags(InputStream in, int offset) throws IOException {
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      tags[offset] = EndianUtils.readSwappedInteger(in);
      offset += numTags;
    }
  }

  return offset;
}
 
源代码4 项目: riiablo   文件: DS1.java
private void readGroups(InputStream in) throws IOException {
  if (version >= 12 && (tagType == 1 || tagType == 2)) {
    if (version >= 18) IOUtils.skip(in, Ints.BYTES);
    numGroups = EndianUtils.readSwappedInteger(in);
    groups = numGroups == 0 ? Group.EMPTY_GROUP_ARRAY : new Group[numGroups];
    for (int i = 0; i < numGroups; i++) {
      groups[i] = new Group().read(version, in);
      if (DEBUG_GROUPS) Gdx.app.debug(TAG, groups[i].toString());
    }
  } else {
    numGroups = 0;
    groups = Group.EMPTY_GROUP_ARRAY;
  }
}
 
源代码5 项目: riiablo   文件: DS1.java
private void readPaths(InputStream in) throws IOException {
  if (version >= 14 && in.available() >= Ints.BYTES) {
    numPaths = EndianUtils.readSwappedInteger(in);
    paths = numPaths == 0 ? Path.EMPTY_PATH_ARRAY : new Path[numPaths];
    for (int i = 0; i < numPaths; i++) {
      Path path = paths[i] = new Path().read(version, objects, in);
      if (DEBUG_PATHS) Gdx.app.debug(TAG, path.toString());
    }
  } else {
    numPaths = 0;
    paths = Path.EMPTY_PATH_ARRAY;
  }
}
 
源代码6 项目: riiablo   文件: DS1.java
Cell read(InputStream in, int orient) throws IOException {
  value       = EndianUtils.readSwappedInteger(in);
  mainIndex   = (short) ((value >>> MAIN_INDEX_OFFSET) & MAIN_INDEX_BITS);
  subIndex    = (short) ((value >>> SUB_INDEX_OFFSET)  & SUB_INDEX_BITS);
  orientation = (short) orient;
  return updateIndex();
}
 
源代码7 项目: riiablo   文件: DS1.java
Object read(int version, InputStream in) throws IOException {
  type  = EndianUtils.readSwappedInteger(in);
  id    = EndianUtils.readSwappedInteger(in);
  x     = EndianUtils.readSwappedInteger(in);
  y     = EndianUtils.readSwappedInteger(in);
  flags = version < 6 ? 0 : EndianUtils.readSwappedInteger(in);
  path  = null;
  return this;
}
 
源代码8 项目: riiablo   文件: DS1.java
Group read(int version, InputStream in) throws IOException {
  if (in.available() >= Ints.BYTES) x      = EndianUtils.readSwappedInteger(in);
  if (in.available() >= Ints.BYTES) y      = EndianUtils.readSwappedInteger(in);
  if (in.available() >= Ints.BYTES) width  = EndianUtils.readSwappedInteger(in);
  if (in.available() >= Ints.BYTES) height = EndianUtils.readSwappedInteger(in);
  if (version >= 13) {
    if (in.available() >= Ints.BYTES) unk  = EndianUtils.readSwappedInteger(in);
  }
  return this;
}
 
源代码9 项目: riiablo   文件: DS1.java
Path read(int version, Object[] objects, InputStream in) throws IOException {
  numPoints = EndianUtils.readSwappedInteger(in);
  points    = new Point[numPoints];
  x         = EndianUtils.readSwappedInteger(in);
  y         = EndianUtils.readSwappedInteger(in);

  Object object = null;
  for (int i = 0; i < objects.length; i++) {
    Object tmp = objects[i];
    if (tmp == null) continue;
    if (tmp.x != x || tmp.y != y) continue;
    if (object != null) Gdx.app.error(TAG, "More than one object is located at path position: " + this);
    object = tmp;
  }

  if (object == null) {
    Gdx.app.error(TAG, "No object associated with path: " + this);
    int skip = (version >= 15 ? 3 : 2) * Ints.BYTES;
    for (int p = 0; p < numPoints; p++) {
      in.skip(skip);
    }

    return this;
  }

  for (int p = 0; p < numPoints; p++) points[p] = new Point().read(version, in);
  object.path = this;
  return this;
}
 
源代码10 项目: riiablo   文件: D2.java
Block(InputStream in) throws IOException {
  numEntries = EndianUtils.readSwappedInteger(in);
  entries = new Entry[numEntries];
  for (int i = 0; i < numEntries; i++) {
    entries[i] = new Entry(in);
    if (DEBUG_ENTRIES) Gdx.app.debug(TAG, entries[i].toString());
  }
}
 
源代码11 项目: AntennaPodSP   文件: VorbisCommentReader.java
private VorbisCommentHeader readCommentHeader(InputStream input)
        throws IOException, VorbisCommentReaderException {
    try {
        long vendorLength = EndianUtils.readSwappedUnsignedInteger(input);
        String vendorName = readUTF8String(input, vendorLength);
        long userCommentLength = EndianUtils
                .readSwappedUnsignedInteger(input);
        return new VorbisCommentHeader(vendorName, userCommentLength);
    } catch (UnsupportedEncodingException e) {
        throw new VorbisCommentReaderException(e);
    }
}
 
源代码12 项目: FontVerter   文件: LittleEndianInputStream.java
public long readUnsignedInt() throws IOException {
    return EndianUtils.readSwappedUnsignedInteger(this);
}
 
源代码13 项目: FontVerter   文件: LittleEndianInputStream.java
public short readShort() throws IOException {
    return EndianUtils.readSwappedShort(this);
}
 
源代码14 项目: FontVerter   文件: LittleEndianInputStream.java
public int readUnsignedShort() throws IOException {
    return EndianUtils.readSwappedUnsignedShort(this);
}
 
源代码15 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeUnsignedShort(int num) throws IOException {
    EndianUtils.writeSwappedShort(stream, (short) num);
}
 
源代码16 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeUnsignedInt(int num) throws IOException {
    EndianUtils.writeSwappedInteger(stream, num);
}
 
源代码17 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeShort(int v) throws IOException {
    EndianUtils.writeSwappedShort(stream, (short) v);
}
 
源代码18 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeInt(int v) throws IOException {
    EndianUtils.writeSwappedInteger(stream, v);
}
 
源代码19 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeLong(long v) throws IOException {
    EndianUtils.writeSwappedLong(stream, v);
}
 
源代码20 项目: FontVerter   文件: LittleEndianOutputStream.java
public void writeFloat(float v) throws IOException {
    EndianUtils.writeSwappedFloat(stream, v);
}
 
源代码21 项目: riiablo   文件: DS1.java
Point read(int version, InputStream in) throws IOException {
  x      = EndianUtils.readSwappedInteger(in);
  y      = EndianUtils.readSwappedInteger(in);
  action = version < 15 ? 1 : EndianUtils.readSwappedInteger(in);
  return this;
}
 
源代码22 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedDouble(InputStream)}. 
 * @return the read long
 * @throws IOException if an I/O error occurs
 * @throws EOFException if an end of file is reached unexpectedly
 */
public double readDouble()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedDouble( in );
}
 
源代码23 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedFloat(InputStream)}. 
 * @return the read long
 * @throws IOException if an I/O error occurs
 * @throws EOFException if an end of file is reached unexpectedly
 */
public float readFloat()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedFloat( in );
}
 
源代码24 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. 
 * @return the read long
 * @throws EOFException if an end of file is reached unexpectedly
 * @throws IOException if an I/O error occurs
 */
public int readInt()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedInteger( in );
}
 
源代码25 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedLong(InputStream)}. 
 * @return the read long
 * @throws EOFException if an end of file is reached unexpectedly
 * @throws IOException if an I/O error occurs
 */
public long readLong()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedLong( in );
}
 
源代码26 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedShort(InputStream)}. 
 * @return the read long
 * @throws EOFException if an end of file is reached unexpectedly
 * @throws IOException if an I/O error occurs
 */
public short readShort()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedShort( in );
}
 
源代码27 项目: aion-germany   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedUnsignedShort(InputStream)}. 
 * @return the read long
 * @throws EOFException if an end of file is reached unexpectedly
 * @throws IOException if an I/O error occurs
 */
public int readUnsignedShort()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedUnsignedShort( in );
}
 
源代码28 项目: lams   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedDouble(InputStream)}. 
 * @return the read long
 * @throws IOException if an I/O error occurs
 * @throws EOFException if an end of file is reached unexpectedly
 */
public double readDouble()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedDouble( in );
}
 
源代码29 项目: lams   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedFloat(InputStream)}. 
 * @return the read long
 * @throws IOException if an I/O error occurs
 * @throws EOFException if an end of file is reached unexpectedly
 */
public float readFloat()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedFloat( in );
}
 
源代码30 项目: lams   文件: SwappedDataInputStream.java
/**
 * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. 
 * @return the read long
 * @throws EOFException if an end of file is reached unexpectedly
 * @throws IOException if an I/O error occurs
 */
public int readInt()
    throws IOException, EOFException
{
    return EndianUtils.readSwappedInteger( in );
}
 
 类所在包
 同包方法