net.augeas
Class Augeas

java.lang.Object
  extended by net.augeas.Augeas

public class Augeas
extends java.lang.Object

Public Augeas API.


Field Summary
protected  AugPointer aug
          Pointert to he active augeas instance.
protected  Aug AugLib
          The augeas library handle
protected  int lastReturn
          The result of the last augeas call.
static int NO_LOAD
          Do not load the tree from AUG_INIT
static int NO_MODL_AUTOLOAD
           
static int NO_STDINC
          Do not use the builtin load path for modules
static int NONE
          Flags to use
protected  boolean raiseExceptions
          If a invalid augeas call (lastReturn = -1) should result in an exception
static int SAVE_BACKUP
          Keep the original file with a .augsave extension
static int SAVE_NEWFILE
          Save changes into a file with extension .augnew, and do not overwrite the original file.
static int SAVE_NOOP
          Make save a no-op process, just record what would have changed
static int TYPE_CHECK
          Typecheck lenses; since it can be very expensive it is not done by default
 
Constructor Summary
Augeas()
          Default constructor that defaults to root and no load path
Augeas(int flags)
          New Augeas instance with only the flags.
Augeas(java.lang.String root, java.lang.String loadpath, int flags)
          Constructs a new Augeas connection
 
Method Summary
protected  void check()
           
 int clear(java.lang.String path)
          Clear the PATH, i.e.
 int clearTransforms()
          Clear all transforms under /augeas/load.
 int close()
          Write all pending changes to disk
 int defineNode(java.lang.String name, java.lang.String expr, java.lang.String value)
          Define a variable NAME whose value is the result of evaluating EXPR, which must be non-NULL and evaluate to a nodeset.
 int defineVariable(java.lang.String name, java.lang.String expr)
          Define a variable NAME whose value is the result of evaluating EXPR.
 boolean exists(java.lang.String path)
          Returns true if the path exists
 java.lang.String get(java.lang.String path)
          Lookup the value associated eith PATH
 int getLastReturn()
          Return the result from the last augeas call.
 boolean getRaiseExceptions()
          if exceptions should be raised
 int insert(java.lang.String path, java.lang.String label, boolean before)
          Create a new sibling LABEL for PATH by inserting into the tree just before PATH if BEFORE == 1 or just after PATH if BEFORE == 0.
 int load()
          Load files into the tree
 java.util.List<java.lang.String> match(java.lang.String path)
          Return a list of the nodes which match the path string
 int move(java.lang.String source, java.lang.String dest)
          Move the node SRC to DST.
protected  void processLastCall(java.lang.String message)
          If the user has opted to throw exceptions on failure, this method will do so based on a return code of -1
 int remove(java.lang.String path)
           
 int rm(java.lang.String path)
          Remove path and all its children.
 int save()
          Write all pending changes to disk
 int set(java.lang.String path, java.lang.String value)
          Set the value associated with PATH to VALUE.
 void setRaiseExceptions(boolean value)
          sets if exceptions should be raised
 int transform(java.lang.String lens, java.lang.String name, java.util.List<java.lang.String> incl, java.util.List<java.lang.String> excl)
          Add a transform under /augeas/load
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static int NONE
Flags to use


SAVE_BACKUP

public static int SAVE_BACKUP
Keep the original file with a .augsave extension


SAVE_NEWFILE

public static int SAVE_NEWFILE
Save changes into a file with extension .augnew, and do not overwrite the original file. Takes precedence over AUG_SAVE_BACKUP


TYPE_CHECK

public static int TYPE_CHECK
Typecheck lenses; since it can be very expensive it is not done by default


NO_STDINC

public static int NO_STDINC
Do not use the builtin load path for modules


SAVE_NOOP

public static int SAVE_NOOP
Make save a no-op process, just record what would have changed


NO_LOAD

public static int NO_LOAD
Do not load the tree from AUG_INIT


NO_MODL_AUTOLOAD

public static int NO_MODL_AUTOLOAD

aug

protected AugPointer aug
Pointert to he active augeas instance.


AugLib

protected Aug AugLib
The augeas library handle


lastReturn

protected int lastReturn
The result of the last augeas call.


raiseExceptions

protected boolean raiseExceptions
If a invalid augeas call (lastReturn = -1) should result in an exception

Constructor Detail

Augeas

public Augeas()
Default constructor that defaults to root and no load path


Augeas

public Augeas(int flags)
New Augeas instance with only the flags.

Parameters:
flags -

Augeas

public Augeas(java.lang.String root,
              java.lang.String loadpath,
              int flags)
Constructs a new Augeas connection

Parameters:
root - or all file lookups
loadpath - path for finding new schemas
flags - any flags to use
Method Detail

check

protected void check()

getRaiseExceptions

public boolean getRaiseExceptions()
if exceptions should be raised


setRaiseExceptions

public void setRaiseExceptions(boolean value)
sets if exceptions should be raised


clear

public int clear(java.lang.String path)
Clear the PATH, i.e. set the value to null

Returns:
0 / -1 based on success/fail

clearTransforms

public int clearTransforms()
Clear all transforms under /augeas/load. If load() is called right after this, there will be no files under +/files+

Returns:
0 / -1 based on success/fail

close

public int close()
Write all pending changes to disk

Returns:
-1 on error, 0 on success

defineNode

public int defineNode(java.lang.String name,
                      java.lang.String expr,
                      java.lang.String value)
Define a variable NAME whose value is the result of evaluating EXPR, which must be non-NULL and evaluate to a nodeset.

Returns:
-1 on error; on success, returns the number of nodes in the nodeset

defineVariable

public int defineVariable(java.lang.String name,
                          java.lang.String expr)
Define a variable NAME whose value is the result of evaluating EXPR.

Returns:
-1 on error; on success, returns 0 if EXPR evaluates to anything other than a nodeset, and the number of nodes if EXPR evaluates to a nodeset

exists

public boolean exists(java.lang.String path)
Returns true if the path exists

Returns:
true if it exists

get

public java.lang.String get(java.lang.String path)
Lookup the value associated eith PATH

Returns:
the value

getLastReturn

public int getLastReturn()
Return the result from the last augeas call.

Returns:

insert

public int insert(java.lang.String path,
                  java.lang.String label,
                  boolean before)
Create a new sibling LABEL for PATH by inserting into the tree just before PATH if BEFORE == 1 or just after PATH if BEFORE == 0.

Returns:
0 on success, and -1 if the insertion fails.

load

public int load()
Load files into the tree

Returns:
-1 on error, 0 on success

match

public java.util.List<java.lang.String> match(java.lang.String path)
Return a list of the nodes which match the path string

Parameters:
path -
Returns:

move

public int move(java.lang.String source,
                java.lang.String dest)
Move the node SRC to DST.

Returns:
0 on success and -1 on failure

remove

public int remove(java.lang.String path)
See Also:
rm

rm

public int rm(java.lang.String path)
Remove path and all its children.

Returns:
-1 / 0 based on fail/success

save

public int save()
Write all pending changes to disk

Returns:
-1 on error, 0 on success

set

public int set(java.lang.String path,
               java.lang.String value)
Set the value associated with PATH to VALUE.

Returns:
0 on success, -1 on error. It is an error if more than one node matches PATH.

transform

public int transform(java.lang.String lens,
                     java.lang.String name,
                     java.util.List<java.lang.String> incl,
                     java.util.List<java.lang.String> excl)
Add a transform under /augeas/load

Parameters:
lens - the lens to use
name - a unique name (optional)
incl - a list of glob patterns to transform
excl - a list of glob patterns to remove
Returns:

processLastCall

protected void processLastCall(java.lang.String message)
If the user has opted to throw exceptions on failure, this method will do so based on a return code of -1