24.08.2015 Views

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

private static final String ARG_PASSWORD ="password";private static final String ARG_SQL ="sql";private static final String ARG_CONNECTION ="connection";<strong>Author</strong> Developer Guide | 1854. You must describe each of the argument name and type. To do this implement the getArguments method whichwill return an array of argument descriptors:public ArgumentDescriptor[] getArguments() {ArgumentDescriptor args[] = new ArgumentDescriptor[] {new ArgumentDescriptor(ARG_JDBC_DRIVER,ArgumentDescriptor.TYPE_STRING,"The name of the Java class that is the JDBC driver."),new ArgumentDescriptor(ARG_CONNECTION,ArgumentDescriptor.TYPE_STRING,"The database URL connection string."),new ArgumentDescriptor(ARG_USER,ArgumentDescriptor.TYPE_STRING,"The name of the database user."),new ArgumentDescriptor(ARG_PASSWORD,ArgumentDescriptor.TYPE_STRING,"The database password."),new ArgumentDescriptor(ARG_SQL,ArgumentDescriptor.TYPE_STRING,"The SQL statement to be executed.")};return args;}These names, types and descriptions will be listed in the Arguments table when the operation is configured.5. When the operation is invoked, the implementation of the doOperation method extracts the arguments, forwardsthem to the method that connects to the database and generates the <strong>XML</strong> fragment. The <strong>XML</strong> fragment is theninserted at the caret position.public void doOperation(<strong>Author</strong>Access authorAccess, ArgumentsMap map)throws IllegalArgumentException, <strong>Author</strong>OperationException {// Collects the arguments.String jdbcDriver =(String)map.getArgumentValue(ARG_JDBC_DRIVER);String connection =(String)map.getArgumentValue(ARG_CONNECTION);String user =(String)map.getArgumentValue(ARG_USER);String password =(String)map.getArgumentValue(ARG_PASSWORD);String sql =(String)map.getArgumentValue(ARG_SQL);int caretPosition = authorAccess.getCaretOffset();try {authorAccess.insert<strong>XML</strong>Fragment(getFragment(jdbcDriver, connection, user, password, sql),caretPosition);} catch (SQLException e) {throw new <strong>Author</strong>OperationException(

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!