public interface INodeChangingCallback
Examples:
Shows how customize node changing with a callback.
public void fontChangeViaCallback() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the node changing callback to custom implementation,
// then add/remove nodes to get it to generate a log.
HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
doc.setNodeChangingCallback(callback);
builder.writeln("Hello world!");
builder.writeln("Hello again!");
builder.insertField(" HYPERLINK \"https://www.google.com/\" ");
builder.insertShape(ShapeType.RECTANGLE, 300.0, 300.0);
doc.getRange().getFields().get(0).remove();
System.out.println(callback.getLog());
}
/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public static class HandleNodeChangingFontChanger implements INodeChangingCallback {
public void nodeInserted(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash:\t{0}", args.getNode().hashCode()));
if (args.getNode().getNodeType() == NodeType.RUN) {
Font font = ((Run) args.getNode()).getFont();
mLog.append(MessageFormat.format("\tFont:\tChanged from \"{0}\" {1}pt", font.getName(), font.getSize()));
font.setSize(24.0);
font.setName("Arial");
mLog.append(MessageFormat.format(" to \"{0}\" {1}pt", font.getName(), font.getSize()));
mLog.append(MessageFormat.format("\tContents:\n\t\t\"{0}\"", args.getNode().getText()));
}
}
public void nodeInserting(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode insertion:", new Date()));
}
public void nodeRemoved(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash code:\t{0}", args.getNode().hashCode()));
}
public void nodeRemoving(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode removal:", new Date()));
}
public String getLog() {
return mLog.toString();
}
private final StringBuilder mLog = new StringBuilder();
}
| Modifier and Type | Method and Description |
|---|---|
void |
nodeInserted(NodeChangingArgs args)
Called when a node belonging to this document has been inserted into another node.
|
void |
nodeInserting(NodeChangingArgs args)
Called just before a node belonging to this document is about to be inserted into another node.
|
void |
nodeRemoved(NodeChangingArgs args)
Called when a node belonging to this document has been removed from its parent.
|
void |
nodeRemoving(NodeChangingArgs args)
Called just before a node belonging to this document is about to be removed from the document.
|
void nodeInserting(NodeChangingArgs args) throws java.lang.Exception
Examples:
Shows how customize node changing with a callback.
public void fontChangeViaCallback() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the node changing callback to custom implementation,
// then add/remove nodes to get it to generate a log.
HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
doc.setNodeChangingCallback(callback);
builder.writeln("Hello world!");
builder.writeln("Hello again!");
builder.insertField(" HYPERLINK \"https://www.google.com/\" ");
builder.insertShape(ShapeType.RECTANGLE, 300.0, 300.0);
doc.getRange().getFields().get(0).remove();
System.out.println(callback.getLog());
}
/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public static class HandleNodeChangingFontChanger implements INodeChangingCallback {
public void nodeInserted(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash:\t{0}", args.getNode().hashCode()));
if (args.getNode().getNodeType() == NodeType.RUN) {
Font font = ((Run) args.getNode()).getFont();
mLog.append(MessageFormat.format("\tFont:\tChanged from \"{0}\" {1}pt", font.getName(), font.getSize()));
font.setSize(24.0);
font.setName("Arial");
mLog.append(MessageFormat.format(" to \"{0}\" {1}pt", font.getName(), font.getSize()));
mLog.append(MessageFormat.format("\tContents:\n\t\t\"{0}\"", args.getNode().getText()));
}
}
public void nodeInserting(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode insertion:", new Date()));
}
public void nodeRemoved(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash code:\t{0}", args.getNode().hashCode()));
}
public void nodeRemoving(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode removal:", new Date()));
}
public String getLog() {
return mLog.toString();
}
private final StringBuilder mLog = new StringBuilder();
}
java.lang.Exceptionvoid nodeInserted(NodeChangingArgs args) throws java.lang.Exception
Examples:
Shows how customize node changing with a callback.
public void fontChangeViaCallback() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the node changing callback to custom implementation,
// then add/remove nodes to get it to generate a log.
HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
doc.setNodeChangingCallback(callback);
builder.writeln("Hello world!");
builder.writeln("Hello again!");
builder.insertField(" HYPERLINK \"https://www.google.com/\" ");
builder.insertShape(ShapeType.RECTANGLE, 300.0, 300.0);
doc.getRange().getFields().get(0).remove();
System.out.println(callback.getLog());
}
/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public static class HandleNodeChangingFontChanger implements INodeChangingCallback {
public void nodeInserted(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash:\t{0}", args.getNode().hashCode()));
if (args.getNode().getNodeType() == NodeType.RUN) {
Font font = ((Run) args.getNode()).getFont();
mLog.append(MessageFormat.format("\tFont:\tChanged from \"{0}\" {1}pt", font.getName(), font.getSize()));
font.setSize(24.0);
font.setName("Arial");
mLog.append(MessageFormat.format(" to \"{0}\" {1}pt", font.getName(), font.getSize()));
mLog.append(MessageFormat.format("\tContents:\n\t\t\"{0}\"", args.getNode().getText()));
}
}
public void nodeInserting(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode insertion:", new Date()));
}
public void nodeRemoved(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash code:\t{0}", args.getNode().hashCode()));
}
public void nodeRemoving(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode removal:", new Date()));
}
public String getLog() {
return mLog.toString();
}
private final StringBuilder mLog = new StringBuilder();
}
java.lang.Exceptionvoid nodeRemoving(NodeChangingArgs args) throws java.lang.Exception
Examples:
Shows how customize node changing with a callback.
public void fontChangeViaCallback() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the node changing callback to custom implementation,
// then add/remove nodes to get it to generate a log.
HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
doc.setNodeChangingCallback(callback);
builder.writeln("Hello world!");
builder.writeln("Hello again!");
builder.insertField(" HYPERLINK \"https://www.google.com/\" ");
builder.insertShape(ShapeType.RECTANGLE, 300.0, 300.0);
doc.getRange().getFields().get(0).remove();
System.out.println(callback.getLog());
}
/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public static class HandleNodeChangingFontChanger implements INodeChangingCallback {
public void nodeInserted(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash:\t{0}", args.getNode().hashCode()));
if (args.getNode().getNodeType() == NodeType.RUN) {
Font font = ((Run) args.getNode()).getFont();
mLog.append(MessageFormat.format("\tFont:\tChanged from \"{0}\" {1}pt", font.getName(), font.getSize()));
font.setSize(24.0);
font.setName("Arial");
mLog.append(MessageFormat.format(" to \"{0}\" {1}pt", font.getName(), font.getSize()));
mLog.append(MessageFormat.format("\tContents:\n\t\t\"{0}\"", args.getNode().getText()));
}
}
public void nodeInserting(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode insertion:", new Date()));
}
public void nodeRemoved(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash code:\t{0}", args.getNode().hashCode()));
}
public void nodeRemoving(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode removal:", new Date()));
}
public String getLog() {
return mLog.toString();
}
private final StringBuilder mLog = new StringBuilder();
}
java.lang.Exceptionvoid nodeRemoved(NodeChangingArgs args) throws java.lang.Exception
Examples:
Shows how customize node changing with a callback.
public void fontChangeViaCallback() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the node changing callback to custom implementation,
// then add/remove nodes to get it to generate a log.
HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
doc.setNodeChangingCallback(callback);
builder.writeln("Hello world!");
builder.writeln("Hello again!");
builder.insertField(" HYPERLINK \"https://www.google.com/\" ");
builder.insertShape(ShapeType.RECTANGLE, 300.0, 300.0);
doc.getRange().getFields().get(0).remove();
System.out.println(callback.getLog());
}
/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public static class HandleNodeChangingFontChanger implements INodeChangingCallback {
public void nodeInserted(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash:\t{0}", args.getNode().hashCode()));
if (args.getNode().getNodeType() == NodeType.RUN) {
Font font = ((Run) args.getNode()).getFont();
mLog.append(MessageFormat.format("\tFont:\tChanged from \"{0}\" {1}pt", font.getName(), font.getSize()));
font.setSize(24.0);
font.setName("Arial");
mLog.append(MessageFormat.format(" to \"{0}\" {1}pt", font.getName(), font.getSize()));
mLog.append(MessageFormat.format("\tContents:\n\t\t\"{0}\"", args.getNode().getText()));
}
}
public void nodeInserting(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode insertion:", new Date()));
}
public void nodeRemoved(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\tType:\t{0}", args.getNode().getNodeType()));
mLog.append(MessageFormat.format("\tHash code:\t{0}", args.getNode().hashCode()));
}
public void nodeRemoving(NodeChangingArgs args) {
mLog.append(MessageFormat.format("\n{0}\tNode removal:", new Date()));
}
public String getLog() {
return mLog.toString();
}
private final StringBuilder mLog = new StringBuilder();
}
java.lang.Exception