com.buglabs.bug.sysfs
Class SysfsNode

java.lang.Object
  extended by com.buglabs.bug.sysfs.SysfsNode
Direct Known Subclasses:
ADXL34xDevice, BMIDevice, BUGBaseControl, LEDDevice, ML8953Device

public abstract class SysfsNode
extends java.lang.Object

An abstract class for files within sysfs. This class has helper methods in dealing with the files.


Field Summary
protected  java.io.File root
           
 
Constructor Summary
SysfsNode(java.io.File root)
           
 
Method Summary
protected static java.lang.String getFirstLineofFile(java.io.File file)
          Return first line of file as a string.
protected static java.lang.String pad(java.lang.String s, int len, char j)
          Pad a string to length len of char j
protected static java.lang.String parseHexInt(java.lang.String sn)
           
protected static int parseInt(java.lang.String sn)
          Null-safe.
protected static java.lang.String parseMultiInt(java.lang.String sn)
          null-safe.
protected  void println(java.io.File file, java.lang.String line)
          Write a line to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected final java.io.File root
Constructor Detail

SysfsNode

public SysfsNode(java.io.File root)
Method Detail

parseMultiInt

protected static java.lang.String parseMultiInt(java.lang.String sn)
null-safe.

Parameters:
sn -
Returns:

parseInt

protected static int parseInt(java.lang.String sn)
Null-safe. Given a number like "0x2f" convert to integer.

Parameters:
sn -
Returns:
the integer or 0 if passed value is null. Invalid numbers will generate exceptions.

parseHexInt

protected static java.lang.String parseHexInt(java.lang.String sn)
Parameters:
sn -
Returns:
the integer as hex or 0 if passed value is null. Invalid numbers will generate exceptions.

pad

protected static java.lang.String pad(java.lang.String s,
                                      int len,
                                      char j)
Pad a string to length len of char j

Parameters:
s -
len -
j -
Returns:

getFirstLineofFile

protected static java.lang.String getFirstLineofFile(java.io.File file)
Return first line of file as a string.

Parameters:
file -
Returns:
first line or null if file read fails (file does not exist, etc.).

println

protected void println(java.io.File file,
                       java.lang.String line)
                throws java.io.IOException
Write a line to a file.

Parameters:
file -
line -
Throws:
java.io.IOException