net.augeas

Class Augeas

public class Augeas extends Object

Public Augeas API.
Field Summary
protected AugAugLib
The augeas library handle
protected AugPointeraug
Pointert to he active augeas instance.
protected intlastReturn
The result of the last augeas call.
static intNONE
Flags to use
static intNO_LOAD
Do not load the tree from AUG_INIT
static intNO_MODL_AUTOLOAD
static intNO_STDINC
Do not use the builtin load path for modules
protected booleanraiseExceptions
If a invalid augeas call (lastReturn = -1) should result in an exception
static intSAVE_BACKUP
Keep the original file with a .augsave extension
static intSAVE_NEWFILE
Save changes into a file with extension .augnew, and do not overwrite the original file.
static intSAVE_NOOP
Make save a no-op process, just record what would have changed
static intTYPE_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(String root, String loadpath, int flags)
Constructs a new Augeas connection
Method Summary
protected voidcheck()
intclear(String path)
Clear the PATH, i.e. set the value to null
intclearTransforms()
Clear all transforms under /augeas/load.
intclose()
Write all pending changes to disk
intdefineNode(String name, String expr, String value)
Define a variable NAME whose value is the result of evaluating EXPR, which must be non-NULL and evaluate to a nodeset.
intdefineVariable(String name, String expr)
Define a variable NAME whose value is the result of evaluating EXPR.
booleanexists(String path)
Returns true if the path exists
Stringget(String path)
Lookup the value associated eith PATH
intgetLastReturn()
Return the result from the last augeas call.
booleangetRaiseExceptions()
if exceptions should be raised
intinsert(String path, 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.
AugeasErrorCodelastError()
Returns the error code from the last method call
StringlastErrorDetails()
Returns the error details from the last method call
StringlastErrorMessage()
Returns the error message from the last method call
StringlastMinorErrorMessage()
Returns the minor error message from the last method call
intload()
Load files into the tree
List<String>match(String path)
Return a list of the nodes which match the path string
intmove(String source, String dest)
Move the node SRC to DST.
protected voidprocessLastCall(String message)
If the user has opted to throw exceptions on failure, this method will do so based on a return code of -1
intremove(String path)
intrm(String path)
Remove path and all its children.
intsave()
Write all pending changes to disk
intset(String path, String value)
Set the value associated with PATH to VALUE.
intsetMany(String base, String sub, String value)
Set the value of multiple nodes in one operation.
voidsetRaiseExceptions(boolean value)
sets if exceptions should be raised
inttransform(String lens, String name, List<String> incl, List<String> excl)
Add a transform under /augeas/load

Field Detail

AugLib

protected Aug AugLib
The augeas library handle

aug

protected AugPointer aug
Pointert to he active augeas instance.

lastReturn

protected int lastReturn
The result of the last augeas call.

NONE

public static int NONE
Flags to use

NO_LOAD

public static int NO_LOAD
Do not load the tree from AUG_INIT

NO_MODL_AUTOLOAD

public static int NO_MODL_AUTOLOAD

NO_STDINC

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

raiseExceptions

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

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

SAVE_NOOP

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

TYPE_CHECK

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

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(String root, 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()

clear

public int clear(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(String name, String expr, 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(String name, 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(String path)
Returns true if the path exists

Returns: true if it exists

get

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

Returns: the value

getLastReturn

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

Returns:

getRaiseExceptions

public boolean getRaiseExceptions()
if exceptions should be raised

insert

public int insert(String path, 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.

lastError

public AugeasErrorCode lastError()
Returns the error code from the last method call

lastErrorDetails

public String lastErrorDetails()
Returns the error details from the last method call

lastErrorMessage

public String lastErrorMessage()
Returns the error message from the last method call

lastMinorErrorMessage

public String lastMinorErrorMessage()
Returns the minor error message from the last method call

load

public int load()
Load files into the tree

Returns: -1 on error, 0 on success

match

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

Parameters: path

Returns:

move

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

Returns: 0 on success and -1 on failure

processLastCall

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

remove

public int remove(String path)

See Also: rm

rm

public int rm(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(String path, 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.

setMany

public int setMany(String base, String sub, String value)
Set the value of multiple nodes in one operation. Find or create a node matching SUB by interpreting SUB as a path expression relative to each node matching BASE. SUB may be NULL, in which case all the nodes matching BASE will be modified.

Returns: number of modified nodes on success, -1 on error

setRaiseExceptions

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

transform

public int transform(String lens, String name, List<String> incl, List<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: