code stringlengths 3 1.18M | language stringclasses 1 value |
|---|---|
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* <P>The AccessibleTextSequence provides information about
* a contiguous sequence of text.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleText
* @see AccessibleAttributeSequence
*
* @author Lynn Monsanto
*/
/** {@collect.stats}
* This class collects together key details of a span of text. It
* is used by implementors of the class <code>AccessibleExtendedText</code> in
* order to return the requested triplet of a <code>String</code>, and the
* start and end indicies/offsets into a larger body of text that the
* <code>String</code> comes from.
*
* @see javax.accessibility.AccessibleExtendedText
*/
public class AccessibleTextSequence {
/* The start index of the text sequence */
public int startIndex;
/** {@collect.stats} The end index of the text sequence */
public int endIndex;
/** {@collect.stats} The text */
public String text;
/** {@collect.stats}
* Constructs an <code>AccessibleTextSequence</code> with the given
* parameters.
*
* @param start the beginning index of the span of text
* @param end the ending index of the span of text
* @param txt the <code>String</code> shared by this text span
*
* @since 1.6
*/
public AccessibleTextSequence(int start, int end, String txt) {
startIndex = start;
endIndex = end;
text = txt;
}
};
| Java |
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.io.InputStream;
import java.awt.datatransfer.DataFlavor;
/** {@collect.stats}
*
* The <code>AccessibleStreamable</code> interface should be implemented
* by the <code>AccessibleContext</code> of any component that presents the
* raw stream behind a component on the display screen. Examples of such
* components are HTML, bitmap images and MathML. An object that implements
* <code>AccessibleStreamable</code> provides two things: a list of MIME
* types supported by the object and a streaming interface for each MIME type to
* get the data.
*
* @author Lynn Monsanto
* @author Peter Korn
*
* @see javax.accessibility.AccessibleContext
* @since 1.5
*/
public interface AccessibleStreamable {
/** {@collect.stats}
* Returns an array of DataFlavor objects for the MIME types
* this object supports.
*
* @return an array of DataFlavor objects for the MIME types
* this object supports.
*/
DataFlavor[] getMimeTypes();
/** {@collect.stats}
* Returns an InputStream for a DataFlavor
*
* @param flavor the DataFlavor
* @return an ImputStream if an ImputStream for this DataFlavor exists.
* Otherwise, null is returned.
*/
InputStream getStream(DataFlavor flavor);
}
| Java |
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* This AccessibleSelection interface
* provides the standard mechanism for an assistive technology to determine
* what the current selected children are, as well as modify the selection set.
* Any object that has children that can be selected should support
* the AccessibleSelection interface. Applications can determine if an object supports the
* AccessibleSelection interface by first obtaining its AccessibleContext (see
* {@link Accessible}) and then calling the
* {@link AccessibleContext#getAccessibleSelection} method.
* If the return value is not null, the object supports this interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleSelection
*
* @author Peter Korn
* @author Hans Muller
* @author Willie Walker
*/
public interface AccessibleSelection {
/** {@collect.stats}
* Returns the number of Accessible children currently selected.
* If no children are selected, the return value will be 0.
*
* @return the number of items currently selected.
*/
public int getAccessibleSelectionCount();
/** {@collect.stats}
* Returns an Accessible representing the specified selected child
* of the object. If there isn't a selection, or there are
* fewer children selected than the integer passed in, the return
* value will be null.
* <p>Note that the index represents the i-th selected child, which
* is different from the i-th child.
*
* @param i the zero-based index of selected children
* @return the i-th selected child
* @see #getAccessibleSelectionCount
*/
public Accessible getAccessibleSelection(int i);
/** {@collect.stats}
* Determines if the current child of this object is selected.
*
* @return true if the current child of this object is selected; else false.
* @param i the zero-based index of the child in this Accessible object.
* @see AccessibleContext#getAccessibleChild
*/
public boolean isAccessibleChildSelected(int i);
/** {@collect.stats}
* Adds the specified Accessible child of the object to the object's
* selection. If the object supports multiple selections,
* the specified child is added to any existing selection, otherwise
* it replaces any existing selection in the object. If the
* specified child is already selected, this method has no effect.
*
* @param i the zero-based index of the child
* @see AccessibleContext#getAccessibleChild
*/
public void addAccessibleSelection(int i);
/** {@collect.stats}
* Removes the specified child of the object from the object's
* selection. If the specified item isn't currently selected, this
* method has no effect.
*
* @param i the zero-based index of the child
* @see AccessibleContext#getAccessibleChild
*/
public void removeAccessibleSelection(int i);
/** {@collect.stats}
* Clears the selection in the object, so that no children in the
* object are selected.
*/
public void clearAccessibleSelection();
/** {@collect.stats}
* Causes every child of the object to be selected
* if the object supports multiple selections.
*/
public void selectAllAccessibleSelection();
}
| Java |
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* Interface Accessible is the main interface for the accessibility package.
* All components that support
* the accessibility package must implement this interface.
* It contains a single method, {@link #getAccessibleContext}, which
* returns an instance of the class {@link AccessibleContext}.
*
* @author Peter Korn
* @author Hans Muller
* @author Willie Walker
*/
public interface Accessible {
/** {@collect.stats}
* Returns the AccessibleContext associated with this object. In most
* cases, the return value should not be null if the object implements
* interface Accessible. If a component developer creates a subclass
* of an object that implements Accessible, and that subclass
* is not Accessible, the developer should override the
* getAccessibleContext method to return null.
*/
public AccessibleContext getAccessibleContext();
}
| Java |
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import javax.swing.text.AttributeSet;
/** {@collect.stats}
* <P>The AccessibleAttributeSequence provides information about
* a contiguous sequence of text attributes
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleText
* @see AccessibleTextSequence
*
* @author Lynn Monsanto
*/
/** {@collect.stats}
* This class collects together the span of text that share the same
* contiguous set of attributes, along with that set of attributes. It
* is used by implementors of the class <code>AccessibleContext</code> in
* order to generate <code>ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED</code> events.
*
* @see javax.accessibility.AccessibleContext
* @see javax.accessibility.AccessibleContext#ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED
*/
public class AccessibleAttributeSequence {
/** {@collect.stats} The start index of the text sequence */
public int startIndex;
/** {@collect.stats} The end index of the text sequence */
public int endIndex;
/** {@collect.stats} The text attributes */
public AttributeSet attributes;
/** {@collect.stats}
* Constructs an <code>AccessibleAttributeSequence</code> with the given
* parameters.
*
* @param start the beginning index of the span of text
* @param end the ending index of the span of text
* @param attr the <code>AttributeSet</code> shared by this text span
*
* @since 1.6
*/
public AccessibleAttributeSequence(int start, int end, AttributeSet attr) {
startIndex = start;
endIndex = end;
attributes = attr;
}
};
| Java |
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* The AccessibleValue interface should be supported by any object
* that supports a numerical value (e.g., a scroll bar). This interface
* provides the standard mechanism for an assistive technology to determine
* and set the numerical value as well as get the minimum and maximum values.
* Applications can determine
* if an object supports the AccessibleValue interface by first
* obtaining its AccessibleContext (see
* {@link Accessible}) and then calling the
* {@link AccessibleContext#getAccessibleValue} method.
* If the return value is not null, the object supports this interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleValue
*
* @author Peter Korn
* @author Hans Muller
* @author Willie Walker
*/
public interface AccessibleValue {
/** {@collect.stats}
* Get the value of this object as a Number. If the value has not been
* set, the return value will be null.
*
* @return value of the object
* @see #setCurrentAccessibleValue
*/
public Number getCurrentAccessibleValue();
/** {@collect.stats}
* Set the value of this object as a Number.
*
* @return True if the value was set; else False
* @see #getCurrentAccessibleValue
*/
public boolean setCurrentAccessibleValue(Number n);
// /** {@collect.stats}
// * Get the description of the value of this object.
// *
// * @return description of the value of the object
// */
// public String getAccessibleValueDescription();
/** {@collect.stats}
* Get the minimum value of this object as a Number.
*
* @return Minimum value of the object; null if this object does not
* have a minimum value
* @see #getMaximumAccessibleValue
*/
public Number getMinimumAccessibleValue();
/** {@collect.stats}
* Get the maximum value of this object as a Number.
*
* @return Maximum value of the object; null if this object does not
* have a maximum value
* @see #getMinimumAccessibleValue
*/
public Number getMaximumAccessibleValue();
}
| Java |
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.Vector;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/** {@collect.stats}
* <P>Class AccessibleState describes a component's particular state. The actual
* state of the component is defined as an AccessibleStateSet, which is a
* composed set of AccessibleStates.
* <p>The toDisplayString method allows you to obtain the localized string
* for a locale independent key from a predefined ResourceBundle for the
* keys defined in this class.
* <p>The constants in this class present a strongly typed enumeration
* of common object roles. A public constructor for this class has been
* purposely omitted and applications should use one of the constants
* from this class. If the constants in this class are not sufficient
* to describe the role of an object, a subclass should be generated
* from this class and it should provide constants in a similar manner.
*
* @author Willie Walker
* @author Peter Korn
*/
public class AccessibleState extends AccessibleBundle {
// If you add or remove anything from here, make sure you
// update AccessibleResourceBundle.java.
/** {@collect.stats}
* Indicates a window is currently the active window. This includes
* windows, dialogs, frames, etc. In addition, this state is used
* to indicate the currently active child of a component such as a
* list, table, or tree. For example, the active child of a list
* is the child that is drawn with a rectangle around it.
* @see AccessibleRole#WINDOW
* @see AccessibleRole#FRAME
* @see AccessibleRole#DIALOG
*/
public static final AccessibleState ACTIVE
= new AccessibleState("active");
/** {@collect.stats}
* Indicates this object is currently pressed. This is usually
* associated with buttons and indicates the user has pressed a
* mouse button while the pointer was over the button and has
* not yet released the mouse button.
* @see AccessibleRole#PUSH_BUTTON
*/
public static final AccessibleState PRESSED
= new AccessibleState("pressed");
/** {@collect.stats}
* Indicates that the object is armed. This is usually used on buttons
* that have been pressed but not yet released, and the mouse pointer
* is still over the button.
* @see AccessibleRole#PUSH_BUTTON
*/
public static final AccessibleState ARMED
= new AccessibleState("armed");
/** {@collect.stats}
* Indicates the current object is busy. This is usually used on objects
* such as progress bars, sliders, or scroll bars to indicate they are
* in a state of transition.
* @see AccessibleRole#PROGRESS_BAR
* @see AccessibleRole#SCROLL_BAR
* @see AccessibleRole#SLIDER
*/
public static final AccessibleState BUSY
= new AccessibleState("busy");
/** {@collect.stats}
* Indicates this object is currently checked. This is usually used on
* objects such as toggle buttons, radio buttons, and check boxes.
* @see AccessibleRole#TOGGLE_BUTTON
* @see AccessibleRole#RADIO_BUTTON
* @see AccessibleRole#CHECK_BOX
*/
public static final AccessibleState CHECKED
= new AccessibleState("checked");
/** {@collect.stats}
* Indicates the user can change the contents of this object. This
* is usually used primarily for objects that allow the user to
* enter text. Other objects, such as scroll bars and sliders,
* are automatically editable if they are enabled.
* @see #ENABLED
*/
public static final AccessibleState EDITABLE
= new AccessibleState("editable");
/** {@collect.stats}
* Indicates this object allows progressive disclosure of its children.
* This is usually used with hierarchical objects such as trees and
* is often paired with the EXPANDED or COLLAPSED states.
* @see #EXPANDED
* @see #COLLAPSED
* @see AccessibleRole#TREE
*/
public static final AccessibleState EXPANDABLE
= new AccessibleState("expandable");
/** {@collect.stats}
* Indicates this object is collapsed. This is usually paired with the
* EXPANDABLE state and is used on objects that provide progressive
* disclosure such as trees.
* @see #EXPANDABLE
* @see #EXPANDED
* @see AccessibleRole#TREE
*/
public static final AccessibleState COLLAPSED
= new AccessibleState("collapsed");
/** {@collect.stats}
* Indicates this object is expanded. This is usually paired with the
* EXPANDABLE state and is used on objects that provide progressive
* disclosure such as trees.
* @see #EXPANDABLE
* @see #COLLAPSED
* @see AccessibleRole#TREE
*/
public static final AccessibleState EXPANDED
= new AccessibleState("expanded");
/** {@collect.stats}
* Indicates this object is enabled. The absence of this state from an
* object's state set indicates this object is not enabled. An object
* that is not enabled cannot be manipulated by the user. In a graphical
* display, it is usually grayed out.
*/
public static final AccessibleState ENABLED
= new AccessibleState("enabled");
/** {@collect.stats}
* Indicates this object can accept keyboard focus, which means all
* events resulting from typing on the keyboard will normally be
* passed to it when it has focus.
* @see #FOCUSED
*/
public static final AccessibleState FOCUSABLE
= new AccessibleState("focusable");
/** {@collect.stats}
* Indicates this object currently has the keyboard focus.
* @see #FOCUSABLE
*/
public static final AccessibleState FOCUSED
= new AccessibleState("focused");
/** {@collect.stats}
* Indicates this object is minimized and is represented only by an
* icon. This is usually only associated with frames and internal
* frames.
* @see AccessibleRole#FRAME
* @see AccessibleRole#INTERNAL_FRAME
*/
public static final AccessibleState ICONIFIED
= new AccessibleState("iconified");
/** {@collect.stats}
* Indicates something must be done with this object before the
* user can interact with an object in a different window. This
* is usually associated only with dialogs.
* @see AccessibleRole#DIALOG
*/
public static final AccessibleState MODAL
= new AccessibleState("modal");
/** {@collect.stats}
* Indicates this object paints every pixel within its
* rectangular region. A non-opaque component paints only some of
* its pixels, allowing the pixels underneath it to "show through".
* A component that does not fully paint its pixels therefore
* provides a degree of transparency.
* @see Accessible#getAccessibleContext
* @see AccessibleContext#getAccessibleComponent
* @see AccessibleComponent#getBounds
*/
public static final AccessibleState OPAQUE
= new AccessibleState("opaque");
/** {@collect.stats}
* Indicates the size of this object is not fixed.
* @see Accessible#getAccessibleContext
* @see AccessibleContext#getAccessibleComponent
* @see AccessibleComponent#getSize
* @see AccessibleComponent#setSize
*/
public static final AccessibleState RESIZABLE
= new AccessibleState("resizable");
/** {@collect.stats}
* Indicates this object allows more than one of its children to
* be selected at the same time.
* @see Accessible#getAccessibleContext
* @see AccessibleContext#getAccessibleSelection
* @see AccessibleSelection
*/
public static final AccessibleState MULTISELECTABLE
= new AccessibleState("multiselectable");
/** {@collect.stats}
* Indicates this object is the child of an object that allows its
* children to be selected, and that this child is one of those
* children that can be selected.
* @see #SELECTED
* @see Accessible#getAccessibleContext
* @see AccessibleContext#getAccessibleSelection
* @see AccessibleSelection
*/
public static final AccessibleState SELECTABLE
= new AccessibleState("selectable");
/** {@collect.stats}
* Indicates this object is the child of an object that allows its
* children to be selected, and that this child is one of those
* children that has been selected.
* @see #SELECTABLE
* @see Accessible#getAccessibleContext
* @see AccessibleContext#getAccessibleSelection
* @see AccessibleSelection
*/
public static final AccessibleState SELECTED
= new AccessibleState("selected");
/** {@collect.stats}
* Indicates this object, the object's parent, the object's parent's
* parent, and so on, are all visible. Note that this does not
* necessarily mean the object is painted on the screen. It might
* be occluded by some other showing object.
* @see #VISIBLE
*/
public static final AccessibleState SHOWING
= new AccessibleState("showing");
/** {@collect.stats}
* Indicates this object is visible. Note: this means that the
* object intends to be visible; however, it may not in fact be
* showing on the screen because one of the objects that this object
* is contained by is not visible.
* @see #SHOWING
*/
public static final AccessibleState VISIBLE
= new AccessibleState("visible");
/** {@collect.stats}
* Indicates the orientation of this object is vertical. This is
* usually associated with objects such as scrollbars, sliders, and
* progress bars.
* @see #VERTICAL
* @see AccessibleRole#SCROLL_BAR
* @see AccessibleRole#SLIDER
* @see AccessibleRole#PROGRESS_BAR
*/
public static final AccessibleState VERTICAL
= new AccessibleState("vertical");
/** {@collect.stats}
* Indicates the orientation of this object is horizontal. This is
* usually associated with objects such as scrollbars, sliders, and
* progress bars.
* @see #HORIZONTAL
* @see AccessibleRole#SCROLL_BAR
* @see AccessibleRole#SLIDER
* @see AccessibleRole#PROGRESS_BAR
*/
public static final AccessibleState HORIZONTAL
= new AccessibleState("horizontal");
/** {@collect.stats}
* Indicates this (text) object can contain only a single line of text
*/
public static final AccessibleState SINGLE_LINE
= new AccessibleState("singleline");
/** {@collect.stats}
* Indicates this (text) object can contain multiple lines of text
*/
public static final AccessibleState MULTI_LINE
= new AccessibleState("multiline");
/** {@collect.stats}
* Indicates this object is transient. An assistive technology should
* not add a PropertyChange listener to an object with transient state,
* as that object will never generate any events. Transient objects
* are typically created to answer Java Accessibility method queries,
* but otherwise do not remain linked to the underlying object (for
* example, those objects underneath lists, tables, and trees in Swing,
* where only one actual UI Component does shared rendering duty for
* all of the data objects underneath the actual list/table/tree elements).
*
* @since 1.5
*
*/
public static final AccessibleState TRANSIENT
= new AccessibleState("transient");
/** {@collect.stats}
* Indicates this object is responsible for managing its
* subcomponents. This is typically used for trees and tables
* that have a large number of subcomponents and where the
* objects are created only when needed and otherwise remain virtual.
* The application should not manage the subcomponents directly.
*
* @since 1.5
*/
public static final AccessibleState MANAGES_DESCENDANTS
= new AccessibleState ("managesDescendants");
/** {@collect.stats}
* Indicates that the object state is indeterminate. An example
* is selected text that is partially bold and partially not
* bold. In this case the attributes associated with the selected
* text are indeterminate.
*
* @since 1.5
*/
public static final AccessibleState INDETERMINATE
= new AccessibleState ("indeterminate");
/** {@collect.stats}
* A state indicating that text is truncated by a bounding rectangle
* and that some of the text is not displayed on the screen. An example
* is text in a spreadsheet cell that is truncated by the bounds of
* the cell.
*
* @since 1.5
*/
static public final AccessibleState TRUNCATED
= new AccessibleState("truncated");
/** {@collect.stats}
* Creates a new AccessibleState using the given locale independent key.
* This should not be a public method. Instead, it is used to create
* the constants in this file to make it a strongly typed enumeration.
* Subclasses of this class should enforce similar policy.
* <p>
* The key String should be a locale independent key for the state.
* It is not intended to be used as the actual String to display
* to the user. To get the localized string, use toDisplayString.
*
* @param key the locale independent name of the state.
* @see AccessibleBundle#toDisplayString
*/
protected AccessibleState(String key) {
this.key = key;
}
}
| Java |
/*
* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* Class AccessibleExtendedTable provides extended information about
* a user-interface component that presents data in a two-dimensional
* table format.
* Applications can determine if an object supports the
* AccessibleExtendedTable interface by first obtaining its
* AccessibleContext and then calling the
* {@link AccessibleContext#getAccessibleTable} method.
* If the return value is not null and the type of the return value is
* AccessibleExtendedTable, the object supports this interface.
*
* @author Lynn Monsanto
* @since 1.4
*/
public interface AccessibleExtendedTable extends AccessibleTable {
/** {@collect.stats}
* Returns the row number of an index in the table.
*
* @param index the zero-based index in the table. The index is
* the table cell offset from row == 0 and column == 0.
* @return the zero-based row of the table if one exists;
* otherwise -1.
*/
public int getAccessibleRow(int index);
/** {@collect.stats}
* Returns the column number of an index in the table.
*
* @param index the zero-based index in the table. The index is
* the table cell offset from row == 0 and column == 0.
* @return the zero-based column of the table if one exists;
* otherwise -1.
*/
public int getAccessibleColumn(int index);
/*
* Returns the index at a row and column in the table.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the zero-based index in the table if one exists;
* otherwise -1. The index is the table cell offset from
* row == 0 and column == 0.
*/
public int getAccessibleIndex(int r, int c);
}
| Java |
/*
* Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.*;
import java.awt.*;
import javax.swing.text.*;
/** {@collect.stats}
* <P>The AccessibleHypertext class is the base class for all
* classes that present hypertext information on the display. This class
* provides the standard mechanism for an assistive technology to access
* that text via its content, attributes, and spatial location.
* It also provides standard mechanisms for manipulating hyperlinks.
* Applications can determine if an object supports the AccessibleHypertext
* interface by first obtaining its AccessibleContext (see {@link Accessible})
* and then calling the {@link AccessibleContext#getAccessibleText}
* method of AccessibleContext. If the return value is a class which extends
* AccessibleHypertext, then that object supports AccessibleHypertext.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleText
* @see AccessibleContext#getAccessibleText
*
* @author Peter Korn
*/
public interface AccessibleHypertext extends AccessibleText {
/** {@collect.stats}
* Returns the number of links within this hypertext document.
*
* @return number of links in this hypertext doc.
*/
public abstract int getLinkCount();
/** {@collect.stats}
* Returns the nth Link of this Hypertext document.
*
* @param linkIndex within the links of this Hypertext
* @return Link object encapsulating the nth link(s)
*/
public abstract AccessibleHyperlink getLink(int linkIndex);
/** {@collect.stats}
* Returns the index into an array of hyperlinks that
* is associated with this character index, or -1 if there
* is no hyperlink associated with this index.
*
* @param charIndex index within the text
* @return index into the set of hyperlinks for this hypertext doc.
*/
public abstract int getLinkIndex(int charIndex);
}
| Java |
/*
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.*;
import java.awt.*;
import javax.swing.text.*;
/** {@collect.stats}
* <P>The AccessibleText interface should be implemented by all
* classes that present textual information on the display. This interface
* provides the standard mechanism for an assistive technology to access
* that text via its content, attributes, and spatial location.
* Applications can determine if an object supports the AccessibleText
* interface by first obtaining its AccessibleContext (see {@link Accessible})
* and then calling the {@link AccessibleContext#getAccessibleText} method of
* AccessibleContext. If the return value is not null, the object supports this
* interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleText
*
* @author Peter Korn
*/
public interface AccessibleText {
/** {@collect.stats}
* Constant used to indicate that the part of the text that should be
* retrieved is a character.
*
* @see #getAtIndex
* @see #getAfterIndex
* @see #getBeforeIndex
*/
public static final int CHARACTER = 1;
/** {@collect.stats}
* Constant used to indicate that the part of the text that should be
* retrieved is a word.
*
* @see #getAtIndex
* @see #getAfterIndex
* @see #getBeforeIndex
*/
public static final int WORD = 2;
/** {@collect.stats}
* Constant used to indicate that the part of the text that should be
* retrieved is a sentence.
*
* A sentence is a string of words which expresses an assertion,
* a question, a command, a wish, an exclamation, or the performance
* of an action. In English locales, the string usually begins with
* a capital letter and concludes with appropriate end punctuation;
* such as a period, question or exclamation mark. Other locales may
* use different capitalization and/or punctuation.
*
* @see #getAtIndex
* @see #getAfterIndex
* @see #getBeforeIndex
*/
public static final int SENTENCE = 3;
/** {@collect.stats}
* Given a point in local coordinates, return the zero-based index
* of the character under that Point. If the point is invalid,
* this method returns -1.
*
* @param p the Point in local coordinates
* @return the zero-based index of the character under Point p; if
* Point is invalid return -1.
*/
public int getIndexAtPoint(Point p);
/** {@collect.stats}
* Determines the bounding box of the character at the given
* index into the string. The bounds are returned in local
* coordinates. If the index is invalid an empty rectangle is returned.
*
* @param i the index into the String
* @return the screen coordinates of the character's bounding box,
* if index is invalid return an empty rectangle.
*/
public Rectangle getCharacterBounds(int i);
/** {@collect.stats}
* Returns the number of characters (valid indicies)
*
* @return the number of characters
*/
public int getCharCount();
/** {@collect.stats}
* Returns the zero-based offset of the caret.
*
* Note: That to the right of the caret will have the same index
* value as the offset (the caret is between two characters).
* @return the zero-based offset of the caret.
*/
public int getCaretPosition();
/** {@collect.stats}
* Returns the String at a given index.
*
* @param part the CHARACTER, WORD, or SENTENCE to retrieve
* @param index an index within the text
* @return the letter, word, or sentence
*/
public String getAtIndex(int part, int index);
/** {@collect.stats}
* Returns the String after a given index.
*
* @param part the CHARACTER, WORD, or SENTENCE to retrieve
* @param index an index within the text
* @return the letter, word, or sentence
*/
public String getAfterIndex(int part, int index);
/** {@collect.stats}
* Returns the String before a given index.
*
* @param part the CHARACTER, WORD, or SENTENCE to retrieve
* @param index an index within the text
* @return the letter, word, or sentence
*/
public String getBeforeIndex(int part, int index);
/** {@collect.stats}
* Returns the AttributeSet for a given character at a given index
*
* @param i the zero-based index into the text
* @return the AttributeSet of the character
*/
public AttributeSet getCharacterAttribute(int i);
/** {@collect.stats}
* Returns the start offset within the selected text.
* If there is no selection, but there is
* a caret, the start and end offsets will be the same.
*
* @return the index into the text of the start of the selection
*/
public int getSelectionStart();
/** {@collect.stats}
* Returns the end offset within the selected text.
* If there is no selection, but there is
* a caret, the start and end offsets will be the same.
*
* @return the index into teh text of the end of the selection
*/
public int getSelectionEnd();
/** {@collect.stats}
* Returns the portion of the text that is selected.
*
* @return the String portion of the text that is selected
*/
public String getSelectedText();
}
| Java |
/*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* The AccessibleTableModelChange interface describes a change to
* the table model. The attributes of the model change can be
* obtained by the following methods:
* <ul>
* <li> public int getType()
* <li> public int getFirstRow();
* <li> public int getLastRow();
* <li> public int getFirstColumn();
* <li> public int getLastColumn();
* </ul>
* The model change type returned by getType() will be one of:
* <ul>
* <li> INSERT - one or more rows and/or columns have been inserted
* <li> UPDATE - some of the table data has changed
* <li> DELETE - one or more rows and/or columns have been deleted
* </ul>
* The affected area of the table can be determined by the other
* four methods which specify ranges of rows and columns
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleTable
*
* @author Lynn Monsanto
* @since 1.3
*/
public interface AccessibleTableModelChange {
/** {@collect.stats}
* Identifies the insertion of new rows and/or columns.
*/
public static final int INSERT = 1;
/** {@collect.stats}
* Identifies a change to existing data.
*/
public static final int UPDATE = 0;
/** {@collect.stats}
* Identifies the deletion of rows and/or columns.
*/
public static final int DELETE = -1;
/** {@collect.stats}
* Returns the type of event
*
* @see #INSERT
* @see #UPDATE
* @see #DELETE
*/
public int getType();
/** {@collect.stats}
* Returns the first row that changed.
*/
public int getFirstRow();
/** {@collect.stats}
* Returns the last row that changed.
*/
public int getLastRow();
/** {@collect.stats}
* Returns the first column that changed.
*/
public int getFirstColumn();
/** {@collect.stats}
* Returns the last column that changed.
*/
public int getLastColumn();
}
| Java |
/*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
/** {@collect.stats}
* The AccessibleIcon interface should be supported by any object
* that has an associated icon (e.g., buttons). This interface
* provides the standard mechanism for an assistive technology
* to get descriptive information about icons.
* Applications can determine
* if an object supports the AccessibleIcon interface by first
* obtaining its AccessibleContext (see
* {@link Accessible}) and then calling the
* {@link AccessibleContext#getAccessibleIcon} method.
* If the return value is not null, the object supports this interface.
*
* @see Accessible
* @see AccessibleContext
*
* @author Lynn Monsanto
* @since 1.3
*/
public interface AccessibleIcon {
/** {@collect.stats}
* Gets the description of the icon. This is meant to be a brief
* textual description of the object. For example, it might be
* presented to a blind user to give an indication of the purpose
* of the icon.
*
* @return the description of the icon
*/
public String getAccessibleIconDescription();
/** {@collect.stats}
* Sets the description of the icon. This is meant to be a brief
* textual description of the object. For example, it might be
* presented to a blind user to give an indication of the purpose
* of the icon.
*
* @param description the description of the icon
*/
public void setAccessibleIconDescription(String description);
/** {@collect.stats}
* Gets the width of the icon
*
* @return the width of the icon.
*/
public int getAccessibleIconWidth();
/** {@collect.stats}
* Gets the height of the icon
*
* @return the height of the icon.
*/
public int getAccessibleIconHeight();
}
| Java |
/*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.Vector;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/** {@collect.stats}
* Class AccessibleRelationSet determines a component's relation set. The
* relation set of a component is a set of AccessibleRelation objects that
* describe the component's relationships with other components.
*
* @see AccessibleRelation
*
* @author Lynn Monsanto
* @since 1.3
*/
public class AccessibleRelationSet {
/** {@collect.stats}
* Each entry in the Vector represents an AccessibleRelation.
* @see #add
* @see #addAll
* @see #remove
* @see #contains
* @see #get
* @see #size
* @see #toArray
* @see #clear
*/
protected Vector<AccessibleRelation> relations = null;
/** {@collect.stats}
* Creates a new empty relation set.
*/
public AccessibleRelationSet() {
relations = null;
}
/** {@collect.stats}
* Creates a new relation with the initial set of relations contained in
* the array of relations passed in. Duplicate entries are ignored.
*
* @param relations an array of AccessibleRelation describing the
* relation set.
*/
public AccessibleRelationSet(AccessibleRelation[] relations) {
if (relations.length != 0) {
this.relations = new Vector(relations.length);
for (int i = 0; i < relations.length; i++) {
add(relations[i]);
}
}
}
/** {@collect.stats}
* Adds a new relation to the current relation set. If the relation
* is already in the relation set, the target(s) of the specified
* relation is merged with the target(s) of the existing relation.
* Otherwise, the new relation is added to the relation set.
*
* @param relation the relation to add to the relation set
* @return true if relation is added to the relation set; false if the
* relation set is unchanged
*/
public boolean add(AccessibleRelation relation) {
if (relations == null) {
relations = new Vector();
}
// Merge the relation targets if the key exists
AccessibleRelation existingRelation = get(relation.getKey());
if (existingRelation == null) {
relations.addElement(relation);
return true;
} else {
Object [] existingTarget = existingRelation.getTarget();
Object [] newTarget = relation.getTarget();
int mergedLength = existingTarget.length + newTarget.length;
Object [] mergedTarget = new Object[mergedLength];
for (int i = 0; i < existingTarget.length; i++) {
mergedTarget[i] = existingTarget[i];
}
for (int i = existingTarget.length, j = 0;
i < mergedLength;
i++, j++) {
mergedTarget[i] = newTarget[j];
}
existingRelation.setTarget(mergedTarget);
}
return true;
}
/** {@collect.stats}
* Adds all of the relations to the existing relation set. Duplicate
* entries are ignored.
*
* @param relations AccessibleRelation array describing the relation set.
*/
public void addAll(AccessibleRelation[] relations) {
if (relations.length != 0) {
if (this.relations == null) {
this.relations = new Vector(relations.length);
}
for (int i = 0; i < relations.length; i++) {
add(relations[i]);
}
}
}
/** {@collect.stats}
* Removes a relation from the current relation set. If the relation
* is not in the set, the relation set will be unchanged and the
* return value will be false. If the relation is in the relation
* set, it will be removed from the set and the return value will be
* true.
*
* @param relation the relation to remove from the relation set
* @return true if the relation is in the relation set; false if the
* relation set is unchanged
*/
public boolean remove(AccessibleRelation relation) {
if (relations == null) {
return false;
} else {
return relations.removeElement(relation);
}
}
/** {@collect.stats}
* Removes all the relations from the current relation set.
*/
public void clear() {
if (relations != null) {
relations.removeAllElements();
}
}
/** {@collect.stats}
* Returns the number of relations in the relation set.
*/
public int size() {
if (relations == null) {
return 0;
} else {
return relations.size();
}
}
/** {@collect.stats}
* Returns whether the relation set contains a relation
* that matches the specified key.
* @param key the AccessibleRelation key
* @return true if the relation is in the relation set; otherwise false
*/
public boolean contains(String key) {
return get(key) != null;
}
/** {@collect.stats}
* Returns the relation that matches the specified key.
* @param key the AccessibleRelation key
* @return the relation, if one exists, that matches the specified key.
* Otherwise, null is returned.
*/
public AccessibleRelation get(String key) {
if (relations == null) {
return null;
} else {
int len = relations.size();
for (int i = 0; i < len; i++) {
AccessibleRelation relation =
(AccessibleRelation)relations.elementAt(i);
if (relation != null && relation.getKey().equals(key)) {
return relation;
}
}
return null;
}
}
/** {@collect.stats}
* Returns the current relation set as an array of AccessibleRelation
* @return AccessibleRelation array contacting the current relation.
*/
public AccessibleRelation[] toArray() {
if (relations == null) {
return new AccessibleRelation[0];
} else {
AccessibleRelation[] relationArray
= new AccessibleRelation[relations.size()];
for (int i = 0; i < relationArray.length; i++) {
relationArray[i] = (AccessibleRelation) relations.elementAt(i);
}
return relationArray;
}
}
/** {@collect.stats}
* Creates a localized String representing all the relations in the set
* using the default locale.
*
* @return comma separated localized String
* @see AccessibleBundle#toDisplayString
*/
public String toString() {
String ret = "";
if ((relations != null) && (relations.size() > 0)) {
ret = ((AccessibleRelation) (relations.elementAt(0))).toDisplayString();
for (int i = 1; i < relations.size(); i++) {
ret = ret + ","
+ ((AccessibleRelation) (relations.elementAt(i))).
toDisplayString();
}
}
return ret;
}
}
| Java |
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/** {@collect.stats}
* <p>Base class used to maintain a strongly typed enumeration. This is
* the superclass of {@link AccessibleState} and {@link AccessibleRole}.
* <p>The toDisplayString method allows you to obtain the localized string
* for a locale independent key from a predefined ResourceBundle for the
* keys defined in this class. This localized string is intended to be
* readable by humans.
*
* @see AccessibleRole
* @see AccessibleState
*
* @author Willie Walker
* @author Peter Korn
* @author Lynn Monsanto
*/
public abstract class AccessibleBundle {
private static Hashtable table = new Hashtable();
private final String defaultResourceBundleName
= "com.sun.accessibility.internal.resources.accessibility";
public AccessibleBundle() {
}
/** {@collect.stats}
* The locale independent name of the state. This is a programmatic
* name that is not intended to be read by humans.
* @see #toDisplayString
*/
protected String key = null;
/** {@collect.stats}
* Obtains the key as a localized string.
* If a localized string cannot be found for the key, the
* locale independent key stored in the role will be returned.
* This method is intended to be used only by subclasses so that they
* can specify their own resource bundles which contain localized
* strings for their keys.
* @param resourceBundleName the name of the resource bundle to use for
* lookup
* @param locale the locale for which to obtain a localized string
* @return a localized String for the key.
*/
protected String toDisplayString(String resourceBundleName,
Locale locale) {
// loads the resource bundle if necessary
loadResourceBundle(resourceBundleName, locale);
// returns the localized string
Object o = table.get(locale);
if (o != null && o instanceof Hashtable) {
Hashtable resourceTable = (Hashtable) o;
o = resourceTable.get(key);
if (o != null && o instanceof String) {
return (String)o;
}
}
return key;
}
/** {@collect.stats}
* Obtains the key as a localized string.
* If a localized string cannot be found for the key, the
* locale independent key stored in the role will be returned.
*
* @param locale the locale for which to obtain a localized string
* @return a localized String for the key.
*/
public String toDisplayString(Locale locale) {
return toDisplayString(defaultResourceBundleName, locale);
}
/** {@collect.stats}
* Gets localized string describing the key using the default locale.
* @return a localized String describing the key for the default locale
*/
public String toDisplayString() {
return toDisplayString(Locale.getDefault());
}
/** {@collect.stats}
* Gets localized string describing the key using the default locale.
* @return a localized String describing the key using the default locale
* @see #toDisplayString
*/
public String toString() {
return toDisplayString();
}
/*
* Loads the Accessibility resource bundle if necessary.
*/
private void loadResourceBundle(String resourceBundleName,
Locale locale) {
if (! table.contains(locale)) {
try {
Hashtable resourceTable = new Hashtable();
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName, locale);
Enumeration iter = bundle.getKeys();
while(iter.hasMoreElements()) {
String key = (String)iter.nextElement();
resourceTable.put(key, bundle.getObject(key));
}
table.put(locale, resourceTable);
}
catch (MissingResourceException e) {
System.err.println("loadResourceBundle: " + e);
// Just return so toDisplayString() returns the
// non-localized key.
return;
}
}
}
}
| Java |
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.*;
import java.awt.*;
import javax.swing.text.*;
/** {@collect.stats}
* <P>The AccessibleExtendedText interface contains additional methods
* not provided by the AccessibleText interface
*
* Applications can determine if an object supports the AccessibleExtendedText
* interface by first obtaining its AccessibleContext (see {@link Accessible})
* and then calling the {@link AccessibleContext#getAccessibleText} method of
* AccessibleContext. If the return value is an instance of
* AccessibleExtendedText, the object supports this interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleText
*
* @author Peter Korn
* @author Lynn Monsanto
* @since 1.5
*/
public interface AccessibleExtendedText {
/** {@collect.stats}
* Constant used to indicate that the part of the text that should be
* retrieved is a line of text.
*
* @see AccessibleText#getAtIndex
* @see AccessibleText#getAfterIndex
* @see AccessibleText#getBeforeIndex
*/
public static final int LINE = 4; // BugID: 4849720
/** {@collect.stats}
* Constant used to indicate that the part of the text that should be
* retrieved is contiguous text with the same text attributes.
*
* @see AccessibleText#getAtIndex
* @see AccessibleText#getAfterIndex
* @see AccessibleText#getBeforeIndex
*/
public static final int ATTRIBUTE_RUN = 5; // BugID: 4849720
/** {@collect.stats}
* Returns the text between two indices
*
* @param startIndex the start index in the text
* @param endIndex the end index in the text
* @return the text string if the indices are valid.
* Otherwise, null is returned.
*/
public String getTextRange(int startIndex, int endIndex);
/** {@collect.stats}
* Returns the <code>AccessibleTextSequence</code> at a given index.
*
* @param part the <code>CHARACTER</code>, <code>WORD</code>,
* <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
* to retrieve
* @param index an index within the text
* @return an <code>AccessibleTextSequence</code> specifying the text
* if part and index are valid. Otherwise, null is returned.
*
* @see AccessibleText#CHARACTER
* @see AccessibleText#WORD
* @see AccessibleText#SENTENCE
*/
public AccessibleTextSequence getTextSequenceAt(int part, int index);
/** {@collect.stats}
* Returns the <code>AccessibleTextSequence</code> after a given index.
*
* @param part the <code>CHARACTER</code>, <code>WORD</code>,
* <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
* to retrieve
* @param index an index within the text
* @return an <code>AccessibleTextSequence</code> specifying the text
* if part and index are valid. Otherwise, null is returned.
*
* @see AccessibleText#CHARACTER
* @see AccessibleText#WORD
* @see AccessibleText#SENTENCE
*/
public AccessibleTextSequence getTextSequenceAfter(int part, int index);
/** {@collect.stats}
* Returns the <code>AccessibleTextSequence</code> before a given index.
*
* @param part the <code>CHARACTER</code>, <code>WORD</code>,
* <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
* to retrieve
* @param index an index within the text
* @return an <code>AccessibleTextSequence</code> specifying the text
* if part and index are valid. Otherwise, null is returned.
*
* @see AccessibleText#CHARACTER
* @see AccessibleText#WORD
* @see AccessibleText#SENTENCE
*/
public AccessibleTextSequence getTextSequenceBefore(int part, int index);
/** {@collect.stats}
* Returns the bounding rectangle of the text between two indices.
*
* @param startIndex the start index in the text
* @param endIndex the end index in the text
* @return the bounding rectangle of the text if the indices are valid.
* Otherwise, null is returned.
*/
public Rectangle getTextBounds(int startIndex, int endIndex);
}
| Java |
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.awt.*;
import java.awt.event.*;
/** {@collect.stats}
* The AccessibleComponent interface should be supported by any object
* that is rendered on the screen. This interface provides the standard
* mechanism for an assistive technology to determine and set the
* graphical representation of an object. Applications can determine
* if an object supports the AccessibleComponent interface by first
* obtaining its AccessibleContext
* and then calling the
* {@link AccessibleContext#getAccessibleComponent} method.
* If the return value is not null, the object supports this interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleComponent
*
* @author Peter Korn
* @author Hans Muller
* @author Willie Walker
*/
public interface AccessibleComponent {
/** {@collect.stats}
* Gets the background color of this object.
*
* @return the background color, if supported, of the object;
* otherwise, null
* @see #setBackground
*/
public Color getBackground();
/** {@collect.stats}
* Sets the background color of this object.
*
* @param c the new Color for the background
* @see #setBackground
*/
public void setBackground(Color c);
/** {@collect.stats}
* Gets the foreground color of this object.
*
* @return the foreground color, if supported, of the object;
* otherwise, null
* @see #setForeground
*/
public Color getForeground();
/** {@collect.stats}
* Sets the foreground color of this object.
*
* @param c the new Color for the foreground
* @see #getForeground
*/
public void setForeground(Color c);
/** {@collect.stats}
* Gets the Cursor of this object.
*
* @return the Cursor, if supported, of the object; otherwise, null
* @see #setCursor
*/
public Cursor getCursor();
/** {@collect.stats}
* Sets the Cursor of this object.
*
* @param cursor the new Cursor for the object
* @see #getCursor
*/
public void setCursor(Cursor cursor);
/** {@collect.stats}
* Gets the Font of this object.
*
* @return the Font,if supported, for the object; otherwise, null
* @see #setFont
*/
public Font getFont();
/** {@collect.stats}
* Sets the Font of this object.
*
* @param f the new Font for the object
* @see #getFont
*/
public void setFont(Font f);
/** {@collect.stats}
* Gets the FontMetrics of this object.
*
* @param f the Font
* @return the FontMetrics, if supported, the object; otherwise, null
* @see #getFont
*/
public FontMetrics getFontMetrics(Font f);
/** {@collect.stats}
* Determines if the object is enabled. Objects that are enabled
* will also have the AccessibleState.ENABLED state set in their
* AccessibleStateSets.
*
* @return true if object is enabled; otherwise, false
* @see #setEnabled
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#ENABLED
* @see AccessibleStateSet
*/
public boolean isEnabled();
/** {@collect.stats}
* Sets the enabled state of the object.
*
* @param b if true, enables this object; otherwise, disables it
* @see #isEnabled
*/
public void setEnabled(boolean b);
/** {@collect.stats}
* Determines if the object is visible. Note: this means that the
* object intends to be visible; however, it may not be
* showing on the screen because one of the objects that this object
* is contained by is currently not visible. To determine if an object is
* showing on the screen, use isShowing().
* <p>Objects that are visible will also have the
* AccessibleState.VISIBLE state set in their AccessibleStateSets.
*
* @return true if object is visible; otherwise, false
* @see #setVisible
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#VISIBLE
* @see AccessibleStateSet
*/
public boolean isVisible();
/** {@collect.stats}
* Sets the visible state of the object.
*
* @param b if true, shows this object; otherwise, hides it
* @see #isVisible
*/
public void setVisible(boolean b);
/** {@collect.stats}
* Determines if the object is showing. This is determined by checking
* the visibility of the object and its ancestors.
* Note: this
* will return true even if the object is obscured by another (for example,
* it is underneath a menu that was pulled down).
*
* @return true if object is showing; otherwise, false
*/
public boolean isShowing();
/** {@collect.stats}
* Checks whether the specified point is within this object's bounds,
* where the point's x and y coordinates are defined to be relative to the
* coordinate system of the object.
*
* @param p the Point relative to the coordinate system of the object
* @return true if object contains Point; otherwise false
* @see #getBounds
*/
public boolean contains(Point p);
/** {@collect.stats}
* Returns the location of the object on the screen.
*
* @return the location of the object on screen; null if this object
* is not on the screen
* @see #getBounds
* @see #getLocation
*/
public Point getLocationOnScreen();
/** {@collect.stats}
* Gets the location of the object relative to the parent in the form
* of a point specifying the object's top-left corner in the screen's
* coordinate space.
*
* @return An instance of Point representing the top-left corner of the
* object's bounds in the coordinate space of the screen; null if
* this object or its parent are not on the screen
* @see #getBounds
* @see #getLocationOnScreen
*/
public Point getLocation();
/** {@collect.stats}
* Sets the location of the object relative to the parent.
* @param p the new position for the top-left corner
* @see #getLocation
*/
public void setLocation(Point p);
/** {@collect.stats}
* Gets the bounds of this object in the form of a Rectangle object.
* The bounds specify this object's width, height, and location
* relative to its parent.
*
* @return A rectangle indicating this component's bounds; null if
* this object is not on the screen.
* @see #contains
*/
public Rectangle getBounds();
/** {@collect.stats}
* Sets the bounds of this object in the form of a Rectangle object.
* The bounds specify this object's width, height, and location
* relative to its parent.
*
* @param r rectangle indicating this component's bounds
* @see #getBounds
*/
public void setBounds(Rectangle r);
/** {@collect.stats}
* Returns the size of this object in the form of a Dimension object.
* The height field of the Dimension object contains this object's
* height, and the width field of the Dimension object contains this
* object's width.
*
* @return A Dimension object that indicates the size of this component;
* null if this object is not on the screen
* @see #setSize
*/
public Dimension getSize();
/** {@collect.stats}
* Resizes this object so that it has width and height.
*
* @param d The dimension specifying the new size of the object.
* @see #getSize
*/
public void setSize(Dimension d);
/** {@collect.stats}
* Returns the Accessible child, if one exists, contained at the local
* coordinate Point.
*
* @param p The point relative to the coordinate system of this object.
* @return the Accessible, if it exists, at the specified location;
* otherwise null
*/
public Accessible getAccessibleAt(Point p);
/** {@collect.stats}
* Returns whether this object can accept focus or not. Objects that
* can accept focus will also have the AccessibleState.FOCUSABLE state
* set in their AccessibleStateSets.
*
* @return true if object can accept focus; otherwise false
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#FOCUSABLE
* @see AccessibleState#FOCUSED
* @see AccessibleStateSet
*/
public boolean isFocusTraversable();
/** {@collect.stats}
* Requests focus for this object. If this object cannot accept focus,
* nothing will happen. Otherwise, the object will attempt to take
* focus.
* @see #isFocusTraversable
*/
public void requestFocus();
/** {@collect.stats}
* Adds the specified focus listener to receive focus events from this
* component.
*
* @param l the focus listener
* @see #removeFocusListener
*/
public void addFocusListener(FocusListener l);
/** {@collect.stats}
* Removes the specified focus listener so it no longer receives focus
* events from this component.
*
* @param l the focus listener
* @see #addFocusListener
*/
public void removeFocusListener(FocusListener l);
}
| Java |
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.Locale;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeEvent;
import java.awt.IllegalComponentStateException;
/** {@collect.stats}
* AccessibleContext represents the minimum information all accessible objects
* return. This information includes the accessible name, description, role,
* and state of the object, as well as information about its parent and
* children. AccessibleContext also contains methods for
* obtaining more specific accessibility information about a component.
* If the component supports them, these methods will return an object that
* implements one or more of the following interfaces:
* <P><ul>
* <li>{@link AccessibleAction} - the object can perform one or more actions.
* This interface provides the standard mechanism for an assistive
* technology to determine what those actions are and tell the object
* to perform them. Any object that can be manipulated should
* support this interface.
* <li>{@link AccessibleComponent} - the object has a graphical representation.
* This interface provides the standard mechanism for an assistive
* technology to determine and set the graphical representation of the
* object. Any object that is rendered on the screen should support
* this interface.
* <li>{@link AccessibleSelection} - the object allows its children to be
* selected. This interface provides the standard mechanism for an
* assistive technology to determine the currently selected children of the object
* as well as modify its selection set. Any object that has children
* that can be selected should support this interface.
* <li>{@link AccessibleText} - the object presents editable textual information
* on the display. This interface provides the standard mechanism for
* an assistive technology to access that text via its content, attributes,
* and spatial location. Any object that contains editable text should
* support this interface.
* <li>{@link AccessibleValue} - the object supports a numerical value. This
* interface provides the standard mechanism for an assistive technology
* to determine and set the current value of the object, as well as obtain its
* minimum and maximum values. Any object that supports a numerical value
* should support this interface.</ul>
*
*
* @beaninfo
* attribute: isContainer false
* description: Minimal information that all accessible objects return
*
* @author Peter Korn
* @author Hans Muller
* @author Willie Walker
* @author Lynn Monsanto
*/
public abstract class AccessibleContext {
/** {@collect.stats}
* Constant used to determine when the accessibleName property has
* changed. The old value in the PropertyChangeEvent will be the old
* accessibleName and the new value will be the new accessibleName.
*
* @see #getAccessibleName
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_NAME_PROPERTY = "AccessibleName";
/** {@collect.stats}
* Constant used to determine when the accessibleDescription property has
* changed. The old value in the PropertyChangeEvent will be the
* old accessibleDescription and the new value will be the new
* accessibleDescription.
*
* @see #getAccessibleDescription
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_DESCRIPTION_PROPERTY = "AccessibleDescription";
/** {@collect.stats}
* Constant used to determine when the accessibleStateSet property has
* changed. The old value will be the old AccessibleState and the new
* value will be the new AccessibleState in the accessibleStateSet.
* For example, if a component that supports the vertical and horizontal
* states changes its orientation from vertical to horizontal, the old
* value will be AccessibleState.VERTICAL and the new value will be
* AccessibleState.HORIZONTAL. Please note that either value can also
* be null. For example, when a component changes from being enabled
* to disabled, the old value will be AccessibleState.ENABLED
* and the new value will be null.
*
* @see #getAccessibleStateSet
* @see AccessibleState
* @see AccessibleStateSet
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_STATE_PROPERTY = "AccessibleState";
/** {@collect.stats}
* Constant used to determine when the accessibleValue property has
* changed. The old value in the PropertyChangeEvent will be a Number
* representing the old value and the new value will be a Number
* representing the new value
*
* @see #getAccessibleValue
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_VALUE_PROPERTY = "AccessibleValue";
/** {@collect.stats}
* Constant used to determine when the accessibleSelection has changed.
* The old and new values in the PropertyChangeEvent are currently
* reserved for future use.
*
* @see #getAccessibleSelection
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_SELECTION_PROPERTY = "AccessibleSelection";
/** {@collect.stats}
* Constant used to determine when the accessibleText caret has changed.
* The old value in the PropertyChangeEvent will be an
* integer representing the old caret position, and the new value will
* be an integer representing the new/current caret position.
*
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_CARET_PROPERTY = "AccessibleCaret";
/** {@collect.stats}
* Constant used to determine when the visual appearance of the object
* has changed. The old and new values in the PropertyChangeEvent are
* currently reserved for future use.
*
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_VISIBLE_DATA_PROPERTY = "AccessibleVisibleData";
/** {@collect.stats}
* Constant used to determine when Accessible children are added/removed
* from the object. If an Accessible child is being added, the old
* value will be null and the new value will be the Accessible child. If an
* Accessible child is being removed, the old value will be the Accessible
* child, and the new value will be null.
*
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_CHILD_PROPERTY = "AccessibleChild";
/** {@collect.stats}
* Constant used to determine when the active descendant of a component
* has changed. The active descendant is used for objects such as
* list, tree, and table, which may have transient children. When the
* active descendant has changed, the old value of the property change
* event will be the Accessible representing the previous active child, and
* the new value will be the Accessible representing the current active
* child.
*
* @see #addPropertyChangeListener
*/
public static final String ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY = "AccessibleActiveDescendant";
/** {@collect.stats}
* Constant used to indicate that the table caption has changed
* The old value in the PropertyChangeEvent will be an Accessible
* representing the previous table caption and the new value will
* be an Accessible representing the new table caption.
* @see Accessible
* @see AccessibleTable
*/
public static final String ACCESSIBLE_TABLE_CAPTION_CHANGED =
"accessibleTableCaptionChanged";
/** {@collect.stats}
* Constant used to indicate that the table summary has changed
* The old value in the PropertyChangeEvent will be an Accessible
* representing the previous table summary and the new value will
* be an Accessible representing the new table summary.
* @see Accessible
* @see AccessibleTable
*/
public static final String ACCESSIBLE_TABLE_SUMMARY_CHANGED =
"accessibleTableSummaryChanged";
/** {@collect.stats}
* Constant used to indicate that table data has changed.
* The old value in the PropertyChangeEvent will be null and the
* new value will be an AccessibleTableModelChange representing
* the table change.
* @see AccessibleTable
* @see AccessibleTableModelChange
*/
public static final String ACCESSIBLE_TABLE_MODEL_CHANGED =
"accessibleTableModelChanged";
/** {@collect.stats}
* Constant used to indicate that the row header has changed
* The old value in the PropertyChangeEvent will be null and the
* new value will be an AccessibleTableModelChange representing
* the header change.
* @see AccessibleTable
* @see AccessibleTableModelChange
*/
public static final String ACCESSIBLE_TABLE_ROW_HEADER_CHANGED =
"accessibleTableRowHeaderChanged";
/** {@collect.stats}
* Constant used to indicate that the row description has changed
* The old value in the PropertyChangeEvent will be null and the
* new value will be an Integer representing the row index.
* @see AccessibleTable
*/
public static final String ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED =
"accessibleTableRowDescriptionChanged";
/** {@collect.stats}
* Constant used to indicate that the column header has changed
* The old value in the PropertyChangeEvent will be null and the
* new value will be an AccessibleTableModelChange representing
* the header change.
* @see AccessibleTable
* @see AccessibleTableModelChange
*/
public static final String ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED =
"accessibleTableColumnHeaderChanged";
/** {@collect.stats}
* Constant used to indicate that the column description has changed
* The old value in the PropertyChangeEvent will be null and the
* new value will be an Integer representing the column index.
* @see AccessibleTable
*/
public static final String ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED =
"accessibleTableColumnDescriptionChanged";
/** {@collect.stats}
* Constant used to indicate that the supported set of actions
* has changed. The old value in the PropertyChangeEvent will
* be an Integer representing the old number of actions supported
* and the new value will be an Integer representing the new
* number of actions supported.
* @see AccessibleAction
*/
public static final String ACCESSIBLE_ACTION_PROPERTY =
"accessibleActionProperty";
/** {@collect.stats}
* Constant used to indicate that a hypertext element has received focus.
* The old value in the PropertyChangeEvent will be an Integer
* representing the start index in the document of the previous element
* that had focus and the new value will be an Integer representing
* the start index in the document of the current element that has
* focus. A value of -1 indicates that an element does not or did
* not have focus.
* @see AccessibleHyperlink
*/
public static final String ACCESSIBLE_HYPERTEXT_OFFSET =
"AccessibleHypertextOffset";
/** {@collect.stats}
* PropertyChangeEvent which indicates that text has changed.
* <br>
* For text insertion, the oldValue is null and the newValue
* is an AccessibleTextSequence specifying the text that was
* inserted.
* <br>
* For text deletion, the oldValue is an AccessibleTextSequence
* specifying the text that was deleted and the newValue is null.
* <br>
* For text replacement, the oldValue is an AccessibleTextSequence
* specifying the old text and the newValue is an AccessibleTextSequence
* specifying the new text.
*
* @see #getAccessibleText
* @see #addPropertyChangeListener
* @see AccessibleTextSequence
*/
public static final String ACCESSIBLE_TEXT_PROPERTY
= "AccessibleText";
/** {@collect.stats}
* PropertyChangeEvent which indicates that a significant change
* has occurred to the children of a component like a tree or text.
* This change notifies the event listener that it needs to
* reacquire the state of the subcomponents. The oldValue is
* null and the newValue is the component whose children have
* become invalid.
*
* @see #getAccessibleText
* @see #addPropertyChangeListener
* @see AccessibleTextSequence
*
* @since 1.5
*/
public static final String ACCESSIBLE_INVALIDATE_CHILDREN =
"accessibleInvalidateChildren";
/** {@collect.stats}
* PropertyChangeEvent which indicates that text attributes have changed.
* <br>
* For attribute insertion, the oldValue is null and the newValue
* is an AccessibleAttributeSequence specifying the attributes that were
* inserted.
* <br>
* For attribute deletion, the oldValue is an AccessibleAttributeSequence
* specifying the attributes that were deleted and the newValue is null.
* <br>
* For attribute replacement, the oldValue is an AccessibleAttributeSequence
* specifying the old attributes and the newValue is an
* AccessibleAttributeSequence specifying the new attributes.
*
* @see #getAccessibleText
* @see #addPropertyChangeListener
* @see AccessibleAttributeSequence
*
* @since 1.5
*/
public static final String ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED =
"accessibleTextAttributesChanged";
/** {@collect.stats}
* PropertyChangeEvent which indicates that a change has occurred
* in a component's bounds.
* The oldValue is the old component bounds and the newValue is
* the new component bounds.
*
* @see #addPropertyChangeListener
*
* @since 1.5
*/
public static final String ACCESSIBLE_COMPONENT_BOUNDS_CHANGED =
"accessibleComponentBoundsChanged";
/** {@collect.stats}
* The accessible parent of this object.
*
* @see #getAccessibleParent
* @see #setAccessibleParent
*/
protected Accessible accessibleParent = null;
/** {@collect.stats}
* A localized String containing the name of the object.
*
* @see #getAccessibleName
* @see #setAccessibleName
*/
protected String accessibleName = null;
/** {@collect.stats}
* A localized String containing the description of the object.
*
* @see #getAccessibleDescription
* @see #setAccessibleDescription
*/
protected String accessibleDescription = null;
/** {@collect.stats}
* Used to handle the listener list for property change events.
*
* @see #addPropertyChangeListener
* @see #removePropertyChangeListener
* @see #firePropertyChangeListener
*/
private PropertyChangeSupport accessibleChangeSupport = null;
/** {@collect.stats}
* Used to represent the context's relation set
* @see #getAccessibleRelationSet
*/
private AccessibleRelationSet relationSet
= new AccessibleRelationSet();
/** {@collect.stats}
* Gets the accessibleName property of this object. The accessibleName
* property of an object is a localized String that designates the purpose
* of the object. For example, the accessibleName property of a label
* or button might be the text of the label or button itself. In the
* case of an object that doesn't display its name, the accessibleName
* should still be set. For example, in the case of a text field used
* to enter the name of a city, the accessibleName for the en_US locale
* could be 'city.'
*
* @return the localized name of the object; null if this
* object does not have a name
*
* @see #setAccessibleName
*/
public String getAccessibleName() {
return accessibleName;
}
/** {@collect.stats}
* Sets the localized accessible name of this object. Changing the
* name will cause a PropertyChangeEvent to be fired for the
* ACCESSIBLE_NAME_PROPERTY property.
*
* @param s the new localized name of the object.
*
* @see #getAccessibleName
* @see #addPropertyChangeListener
*
* @beaninfo
* preferred: true
* description: Sets the accessible name for the component.
*/
public void setAccessibleName(String s) {
String oldName = accessibleName;
accessibleName = s;
firePropertyChange(ACCESSIBLE_NAME_PROPERTY,oldName,accessibleName);
}
/** {@collect.stats}
* Gets the accessibleDescription property of this object. The
* accessibleDescription property of this object is a short localized
* phrase describing the purpose of the object. For example, in the
* case of a 'Cancel' button, the accessibleDescription could be
* 'Ignore changes and close dialog box.'
*
* @return the localized description of the object; null if
* this object does not have a description
*
* @see #setAccessibleDescription
*/
public String getAccessibleDescription() {
return accessibleDescription;
}
/** {@collect.stats}
* Sets the accessible description of this object. Changing the
* name will cause a PropertyChangeEvent to be fired for the
* ACCESSIBLE_DESCRIPTION_PROPERTY property.
*
* @param s the new localized description of the object
*
* @see #setAccessibleName
* @see #addPropertyChangeListener
*
* @beaninfo
* preferred: true
* description: Sets the accessible description for the component.
*/
public void setAccessibleDescription(String s) {
String oldDescription = accessibleDescription;
accessibleDescription = s;
firePropertyChange(ACCESSIBLE_DESCRIPTION_PROPERTY,
oldDescription,accessibleDescription);
}
/** {@collect.stats}
* Gets the role of this object. The role of the object is the generic
* purpose or use of the class of this object. For example, the role
* of a push button is AccessibleRole.PUSH_BUTTON. The roles in
* AccessibleRole are provided so component developers can pick from
* a set of predefined roles. This enables assistive technologies to
* provide a consistent interface to various tweaked subclasses of
* components (e.g., use AccessibleRole.PUSH_BUTTON for all components
* that act like a push button) as well as distinguish between sublasses
* that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes
* and AccessibleRole.RADIO_BUTTON for radio buttons).
* <p>Note that the AccessibleRole class is also extensible, so
* custom component developers can define their own AccessibleRole's
* if the set of predefined roles is inadequate.
*
* @return an instance of AccessibleRole describing the role of the object
* @see AccessibleRole
*/
public abstract AccessibleRole getAccessibleRole();
/** {@collect.stats}
* Gets the state set of this object. The AccessibleStateSet of an object
* is composed of a set of unique AccessibleStates. A change in the
* AccessibleStateSet of an object will cause a PropertyChangeEvent to
* be fired for the ACCESSIBLE_STATE_PROPERTY property.
*
* @return an instance of AccessibleStateSet containing the
* current state set of the object
* @see AccessibleStateSet
* @see AccessibleState
* @see #addPropertyChangeListener
*/
public abstract AccessibleStateSet getAccessibleStateSet();
/** {@collect.stats}
* Gets the Accessible parent of this object.
*
* @return the Accessible parent of this object; null if this
* object does not have an Accessible parent
*/
public Accessible getAccessibleParent() {
return accessibleParent;
}
/** {@collect.stats}
* Sets the Accessible parent of this object. This is meant to be used
* only in the situations where the actual component's parent should
* not be treated as the component's accessible parent and is a method
* that should only be called by the parent of the accessible child.
*
* @param a - Accessible to be set as the parent
*/
public void setAccessibleParent(Accessible a) {
accessibleParent = a;
}
/** {@collect.stats}
* Gets the 0-based index of this object in its accessible parent.
*
* @return the 0-based index of this object in its parent; -1 if this
* object does not have an accessible parent.
*
* @see #getAccessibleParent
* @see #getAccessibleChildrenCount
* @see #getAccessibleChild
*/
public abstract int getAccessibleIndexInParent();
/** {@collect.stats}
* Returns the number of accessible children of the object.
*
* @return the number of accessible children of the object.
*/
public abstract int getAccessibleChildrenCount();
/** {@collect.stats}
* Returns the specified Accessible child of the object. The Accessible
* children of an Accessible object are zero-based, so the first child
* of an Accessible child is at index 0, the second child is at index 1,
* and so on.
*
* @param i zero-based index of child
* @return the Accessible child of the object
* @see #getAccessibleChildrenCount
*/
public abstract Accessible getAccessibleChild(int i);
/** {@collect.stats}
* Gets the locale of the component. If the component does not have a
* locale, then the locale of its parent is returned.
*
* @return this component's locale. If this component does not have
* a locale, the locale of its parent is returned.
*
* @exception IllegalComponentStateException
* If the Component does not have its own locale and has not yet been
* added to a containment hierarchy such that the locale can be
* determined from the containing parent.
*/
public abstract Locale getLocale() throws IllegalComponentStateException;
/** {@collect.stats}
* Adds a PropertyChangeListener to the listener list.
* The listener is registered for all Accessible properties and will
* be called when those properties change.
*
* @see #ACCESSIBLE_NAME_PROPERTY
* @see #ACCESSIBLE_DESCRIPTION_PROPERTY
* @see #ACCESSIBLE_STATE_PROPERTY
* @see #ACCESSIBLE_VALUE_PROPERTY
* @see #ACCESSIBLE_SELECTION_PROPERTY
* @see #ACCESSIBLE_TEXT_PROPERTY
* @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
*
* @param listener The PropertyChangeListener to be added
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (accessibleChangeSupport == null) {
accessibleChangeSupport = new PropertyChangeSupport(this);
}
accessibleChangeSupport.addPropertyChangeListener(listener);
}
/** {@collect.stats}
* Removes a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
* for all properties.
*
* @param listener The PropertyChangeListener to be removed
*/
public void removePropertyChangeListener(PropertyChangeListener listener) {
if (accessibleChangeSupport != null) {
accessibleChangeSupport.removePropertyChangeListener(listener);
}
}
/** {@collect.stats}
* Gets the AccessibleAction associated with this object that supports
* one or more actions.
*
* @return AccessibleAction if supported by object; else return null
* @see AccessibleAction
*/
public AccessibleAction getAccessibleAction() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleComponent associated with this object that has a
* graphical representation.
*
* @return AccessibleComponent if supported by object; else return null
* @see AccessibleComponent
*/
public AccessibleComponent getAccessibleComponent() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleSelection associated with this object which allows its
* Accessible children to be selected.
*
* @return AccessibleSelection if supported by object; else return null
* @see AccessibleSelection
*/
public AccessibleSelection getAccessibleSelection() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleText associated with this object presenting
* text on the display.
*
* @return AccessibleText if supported by object; else return null
* @see AccessibleText
*/
public AccessibleText getAccessibleText() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleEditableText associated with this object
* presenting editable text on the display.
*
* @return AccessibleEditableText if supported by object; else return null
* @see AccessibleEditableText
* @since 1.4
*/
public AccessibleEditableText getAccessibleEditableText() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleValue associated with this object that supports a
* Numerical value.
*
* @return AccessibleValue if supported by object; else return null
* @see AccessibleValue
*/
public AccessibleValue getAccessibleValue() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleIcons associated with an object that has
* one or more associated icons
*
* @return an array of AccessibleIcon if supported by object;
* otherwise return null
* @see AccessibleIcon
* @since 1.3
*/
public AccessibleIcon [] getAccessibleIcon() {
return null;
}
/** {@collect.stats}
* Gets the AccessibleRelationSet associated with an object
*
* @return an AccessibleRelationSet if supported by object;
* otherwise return null
* @see AccessibleRelationSet
* @since 1.3
*/
public AccessibleRelationSet getAccessibleRelationSet() {
return relationSet;
}
/** {@collect.stats}
* Gets the AccessibleTable associated with an object
*
* @return an AccessibleTable if supported by object;
* otherwise return null
* @see AccessibleTable
* @since 1.3
*/
public AccessibleTable getAccessibleTable() {
return null;
}
/** {@collect.stats}
* Support for reporting bound property changes. If oldValue and
* newValue are not equal and the PropertyChangeEvent listener list
* is not empty, then fire a PropertyChange event to each listener.
* In general, this is for use by the Accessible objects themselves
* and should not be called by an application program.
* @param propertyName The programmatic name of the property that
* was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @see java.beans.PropertyChangeSupport
* @see #addPropertyChangeListener
* @see #removePropertyChangeListener
* @see #ACCESSIBLE_NAME_PROPERTY
* @see #ACCESSIBLE_DESCRIPTION_PROPERTY
* @see #ACCESSIBLE_STATE_PROPERTY
* @see #ACCESSIBLE_VALUE_PROPERTY
* @see #ACCESSIBLE_SELECTION_PROPERTY
* @see #ACCESSIBLE_TEXT_PROPERTY
* @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
*/
public void firePropertyChange(String propertyName,
Object oldValue,
Object newValue) {
if (accessibleChangeSupport != null) {
if (newValue instanceof PropertyChangeEvent) {
PropertyChangeEvent pce = (PropertyChangeEvent)newValue;
accessibleChangeSupport.firePropertyChange(pce);
} else {
accessibleChangeSupport.firePropertyChange(propertyName,
oldValue,
newValue);
}
}
}
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.accessibility;
import java.util.*;
import java.awt.*;
import javax.swing.text.*;
/** {@collect.stats}
* <P>The AccessibleEditableText interface should be implemented by all
* classes that present editable textual information on the display.
* Along with the AccessibleText interface, this interface provides
* the standard mechanism for an assistive technology to access
* that text via its content, attributes, and spatial location.
* Applications can determine if an object supports the AccessibleEditableText
* interface by first obtaining its AccessibleContext (see {@link Accessible})
* and then calling the {@link AccessibleContext#getAccessibleEditableText}
* method of AccessibleContext. If the return value is not null, the object
* supports this interface.
*
* @see Accessible
* @see Accessible#getAccessibleContext
* @see AccessibleContext
* @see AccessibleContext#getAccessibleText
* @see AccessibleContext#getAccessibleEditableText
*
* @author Lynn Monsanto
* @since 1.4
*/
public interface AccessibleEditableText extends AccessibleText {
/** {@collect.stats}
* Sets the text contents to the specified string.
*
* @param s the string to set the text contents
*/
public void setTextContents(String s);
/** {@collect.stats}
* Inserts the specified string at the given index/
*
* @param index the index in the text where the string will
* be inserted
* @param s the string to insert in the text
*/
public void insertTextAtIndex(int index, String s);
/** {@collect.stats}
* Returns the text string between two indices.
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
* @return the text string between the indices
*/
public String getTextRange(int startIndex, int endIndex);
/** {@collect.stats}
* Deletes the text between two indices
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
*/
public void delete(int startIndex, int endIndex);
/** {@collect.stats}
* Cuts the text between two indices into the system clipboard.
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
*/
public void cut(int startIndex, int endIndex);
/** {@collect.stats}
* Pastes the text from the system clipboard into the text
* starting at the specified index.
*
* @param startIndex the starting index in the text
*/
public void paste(int startIndex);
/** {@collect.stats}
* Replaces the text between two indices with the specified
* string.
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
* @param s the string to replace the text between two indices
*/
public void replaceText(int startIndex, int endIndex, String s);
/** {@collect.stats}
* Selects the text between two indices.
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
*/
public void selectText(int startIndex, int endIndex);
/** {@collect.stats}
* Sets attributes for the text between two indices.
*
* @param startIndex the starting index in the text
* @param endIndex the ending index in the text
* @param as the attribute set
* @see AttributeSet
*/
public void setAttributes(int startIndex, int endIndex, AttributeSet as);
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: NoSuchMechanismException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.io.PrintStream;
import java.io.PrintWriter;
import javax.xml.crypto.dsig.Manifest;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
/** {@collect.stats}
* This exception is thrown when a particular XML mechanism is requested but
* is not available in the environment.
*
* <p>A <code>NoSuchMechanismException</code> can contain a cause: another
* throwable that caused this <code>NoSuchMechanismException</code> to get
* thrown.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#getInstance XMLSignatureFactory.getInstance
* @see KeyInfoFactory#getInstance KeyInfoFactory.getInstance
*/
public class NoSuchMechanismException extends RuntimeException {
private static final long serialVersionUID = 4189669069570660166L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or null if this
* exception was not caused by another throwable or if the causative
* throwable is unknown.
*
* @serial
*/
private Throwable cause;
/** {@collect.stats}
* Constructs a new <code>NoSuchMechanismException</code> with
* <code>null</code> as its detail message.
*/
public NoSuchMechanismException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>NoSuchMechanismException</code> with the
* specified detail message.
*
* @param message the detail message
*/
public NoSuchMechanismException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>NoSuchMechanismException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public NoSuchMechanismException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>NoSuchMechanismException</code> with the
* specified cause and a detail message of
* <code>(cause==null ? null : cause.toString())</code> (which typically
* contains the class and detail message of <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public NoSuchMechanismException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the cause of this <code>NoSuchMechanismException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>NoSuchMechanismException</code> to get thrown.)
*
* @return the cause of this <code>NoSuchMechanismException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>NoSuchMechanismException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>NoSuchMechanismException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>NoSuchMechanismException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: URIReference.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
/** {@collect.stats}
* Identifies a data object via a URI-Reference, as specified by
* <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>.
*
* <p>Note that some subclasses may not have a <code>type</code> attribute
* and for objects of those types, the {@link #getType} method always returns
* <code>null</code>.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see URIDereferencer
*/
public interface URIReference {
/** {@collect.stats}
* Returns the URI of the referenced data object.
*
* @return the URI of the data object in RFC 2396 format (may be
* <code>null</code> if not specified)
*/
String getURI();
/** {@collect.stats}
* Returns the type of data referenced by this URI.
*
* @return the type (a URI) of the data object (may be <code>null</code>
* if not specified)
*/
String getType();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: Data.java,v 1.4 2005/05/10 15:47:41 mullan Exp $
*/
package javax.xml.crypto;
import javax.xml.crypto.dsig.Transform;
/** {@collect.stats}
* An abstract representation of the result of dereferencing a
* {@link URIReference} or the input/output of subsequent {@link Transform}s.
* The primary purpose of this interface is to group and provide type safety
* for all <code>Data</code> subtypes.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface Data { }
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeySelectorResult.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.security.Key;
/** {@collect.stats}
* The result returned by the {@link KeySelector#select KeySelector.select}
* method.
* <p>
* At a minimum, a <code>KeySelectorResult</code> contains the <code>Key</code>
* selected by the <code>KeySelector</code>. Implementations of this interface
* may add methods to return implementation or algorithm specific information,
* such as a chain of certificates or debugging information.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeySelector
*/
public interface KeySelectorResult {
/** {@collect.stats}
* Returns the selected key.
*
* @return the selected key, or <code>null</code> if none can be found
*/
Key getKey();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignatureProperty.java,v 1.4 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.XMLStructure;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>SignatureProperty</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <pre><code>
*<element name="SignatureProperty" type="ds:SignaturePropertyType"/>
* <complexType name="SignaturePropertyType" mixed="true">
* <choice maxOccurs="unbounded">
* <any namespace="##other" processContents="lax"/>
* <!-- (1,1) elements from (1, unbounded) namespaces -->
* </choice>
* <attribute name="Target" type="anyURI" use="required"/>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </code></pre>
*
* A <code>SignatureProperty</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newSignatureProperty newSignatureProperty}
* method of the {@link XMLSignatureFactory} class; for example:
*
* <pre>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* SignatureProperty property = factory.newSignatureProperty
* (Collections.singletonList(content), "#Signature-1", "TimeStamp");
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newSignatureProperty(List, String, String)
* @see SignatureProperties
*/
public interface SignatureProperty extends XMLStructure {
/** {@collect.stats}
* Returns the target URI of this <code>SignatureProperty</code>.
*
* @return the target URI of this <code>SignatureProperty</code> (never
* <code>null</code>)
*/
String getTarget();
/** {@collect.stats}
* Returns the Id of this <code>SignatureProperty</code>.
*
* @return the Id of this <code>SignatureProperty</code> (or
* <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of one or more {@link XMLStructure}s that are contained in
* this <code>SignatureProperty</code>. These represent additional
* information items concerning the generation of the {@link XMLSignature}
* (i.e. date/time stamp or serial numbers of cryptographic hardware used
* in signature generation).
*
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
*/
List getContent();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: Manifest.java,v 1.7 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.XMLStructure;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>Manifest</code> element as defined in
* the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <pre><code>
* <element name="Manifest" type="ds:ManifestType"/>
* <complexType name="ManifestType">
* <sequence>
* <element ref="ds:Reference" maxOccurs="unbounded"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </code></pre>
*
* A <code>Manifest</code> instance may be created by invoking
* one of the {@link XMLSignatureFactory#newManifest newManifest}
* methods of the {@link XMLSignatureFactory} class; for example:
*
* <pre>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* List references = Collections.singletonList(factory.newReference
* ("#reference-1", DigestMethod.SHA1));
* Manifest manifest = factory.newManifest(references, "manifest-1");
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newManifest(List)
* @see XMLSignatureFactory#newManifest(List, String)
*/
public interface Manifest extends XMLStructure {
/** {@collect.stats}
* URI that identifies the <code>Manifest</code> element (this can be
* specified as the value of the <code>type</code> parameter of the
* {@link Reference} class to identify the referent's type).
*/
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#Manifest";
/** {@collect.stats}
* Returns the Id of this <code>Manifest</code>.
*
* @return the Id of this <code>Manifest</code> (or <code>null</code>
* if not specified)
*/
String getId();
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of one or more {@link Reference}s that are contained in this
* <code>Manifest</code>.
*
* @return an unmodifiable list of one or more <code>Reference</code>s
*/
List getReferences();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignatureProperties.java,v 1.4 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.XMLStructure;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>SignatureProperties</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <pre><code>
*<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
* <complexType name="SignaturePropertiesType">
* <sequence>
* <element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </code></pre>
*
* A <code>SignatureProperties</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newSignatureProperties newSignatureProperties}
* method of the {@link XMLSignatureFactory} class; for example:
*
* <pre>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* SignatureProperties properties =
* factory.newSignatureProperties(props, "signature-properties-1");
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newSignatureProperties(List, String)
* @see SignatureProperty
*/
public interface SignatureProperties extends XMLStructure {
/** {@collect.stats}
* URI that identifies the <code>SignatureProperties</code> element (this
* can be specified as the value of the <code>type</code> parameter of the
* {@link Reference} class to identify the referent's type).
*/
final static String TYPE =
"http://www.w3.org/2000/09/xmldsig#SignatureProperties";
/** {@collect.stats}
* Returns the Id of this <code>SignatureProperties</code>.
*
* @return the Id of this <code>SignatureProperties</code> (or
* <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of one or more {@link SignatureProperty}s that are contained in
* this <code>SignatureProperties</code>.
*
* @return an unmodifiable list of one or more
* <code>SignatureProperty</code>s
*/
List getProperties();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
*
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
*
* ===========================================================================
*/
/*
* $Id: XMLSignature.java,v 1.10 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.KeySelectorResult;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import java.security.Signature;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>Signature</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* This class contains methods for signing and validating XML signatures
* with behavior as defined by the W3C specification. The XML Schema Definition
* is defined as:
* <pre><code>
* <element name="Signature" type="ds:SignatureType"/>
* <complexType name="SignatureType">
* <sequence>
* <element ref="ds:SignedInfo"/>
* <element ref="ds:SignatureValue"/>
* <element ref="ds:KeyInfo" minOccurs="0"/>
* <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </code></pre>
* <p>
* An <code>XMLSignature</code> instance may be created by invoking one of the
* {@link XMLSignatureFactory#newXMLSignature newXMLSignature} methods of the
* {@link XMLSignatureFactory} class.
*
* <p>If the contents of the underlying document containing the
* <code>XMLSignature</code> are subsequently modified, the behavior is
* undefined.
*
* <p>Note that this class is named <code>XMLSignature</code> rather than
* <code>Signature</code> to avoid naming clashes with the existing
* {@link Signature java.security.Signature} class.
*
* @see XMLSignatureFactory#newXMLSignature(SignedInfo, KeyInfo)
* @see XMLSignatureFactory#newXMLSignature(SignedInfo, KeyInfo, List, String, String)
* @author Joyce L. Leung
* @author Sean Mullan
* @author Erwin van der Koogh
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface XMLSignature extends XMLStructure {
/** {@collect.stats}
* The XML Namespace URI of the W3C Recommendation for XML-Signature
* Syntax and Processing.
*/
final static String XMLNS = "http://www.w3.org/2000/09/xmldsig#";
/** {@collect.stats}
* Validates the signature according to the
* <a href="http://www.w3.org/TR/xmldsig-core/#sec-CoreValidation">
* core validation processing rules</a>. This method validates the
* signature using the existing state, it does not unmarshal and
* reinitialize the contents of the <code>XMLSignature</code> using the
* location information specified in the context.
*
* <p>This method only validates the signature the first time it is
* invoked. On subsequent invocations, it returns a cached result.
*
* @param validateContext the validating context
* @return <code>true</code> if the signature passed core validation,
* otherwise <code>false</code>
* @throws ClassCastException if the type of <code>validateContext</code>
* is not compatible with this <code>XMLSignature</code>
* @throws NullPointerException if <code>validateContext</code> is
* <code>null</code>
* @throws XMLSignatureException if an unexpected error occurs during
* validation that prevented the validation operation from completing
*/
boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException;
/** {@collect.stats}
* Returns the key info of this <code>XMLSignature</code>.
*
* @return the key info (may be <code>null</code> if not specified)
*/
KeyInfo getKeyInfo();
/** {@collect.stats}
* Returns the signed info of this <code>XMLSignature</code>.
*
* @return the signed info (never <code>null</code>)
*/
SignedInfo getSignedInfo();
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of {@link XMLObject}s contained in this <code>XMLSignature</code>.
*
* @return an unmodifiable list of <code>XMLObject</code>s (may be empty
* but never <code>null</code>)
*/
List getObjects();
/** {@collect.stats}
* Returns the optional Id of this <code>XMLSignature</code>.
*
* @return the Id (may be <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Returns the signature value of this <code>XMLSignature</code>.
*
* @return the signature value
*/
SignatureValue getSignatureValue();
/** {@collect.stats}
* Signs this <code>XMLSignature</code>.
*
* <p>If this method throws an exception, this <code>XMLSignature</code> and
* the <code>signContext</code> parameter will be left in the state that
* it was in prior to the invocation.
*
* @param signContext the signing context
* @throws ClassCastException if the type of <code>signContext</code> is
* not compatible with this <code>XMLSignature</code>
* @throws NullPointerException if <code>signContext</code> is
* <code>null</code>
* @throws MarshalException if an exception occurs while marshalling
* @throws XMLSignatureException if an unexpected exception occurs while
* generating the signature
*/
void sign(XMLSignContext signContext) throws MarshalException,
XMLSignatureException;
/** {@collect.stats}
* Returns the result of the {@link KeySelector}, if specified, after
* this <code>XMLSignature</code> has been signed or validated.
*
* @return the key selector result, or <code>null</code> if a key
* selector has not been specified or this <code>XMLSignature</code>
* has not been signed or validated
*/
KeySelectorResult getKeySelectorResult();
/** {@collect.stats}
* A representation of the XML <code>SignatureValue</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <p>
* <pre>
* <element name="SignatureValue" type="ds:SignatureValueType"/>
* <complexType name="SignatureValueType">
* <simpleContent>
* <extension base="base64Binary">
* <attribute name="Id" type="ID" use="optional"/>
* </extension>
* </simpleContent>
* </complexType>
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
*/
public interface SignatureValue extends XMLStructure {
/** {@collect.stats}
* Returns the optional <code>Id</code> attribute of this
* <code>SignatureValue</code>, which permits this element to be
* referenced from elsewhere.
*
* @return the <code>Id</code> attribute (may be <code>null</code> if
* not specified)
*/
String getId();
/** {@collect.stats}
* Returns the signature value of this <code>SignatureValue</code>.
*
* @return the signature value (may be <code>null</code> if the
* <code>XMLSignature</code> has not been signed yet). Each
* invocation of this method returns a new clone of the array to
* prevent subsequent modification.
*/
byte[] getValue();
/** {@collect.stats}
* Validates the signature value. This method performs a
* cryptographic validation of the signature calculated over the
* <code>SignedInfo</code> of the <code>XMLSignature</code>.
*
* <p>This method only validates the signature the first
* time it is invoked. On subsequent invocations, it returns a cached
* result.
*
* @return <code>true</code> if the signature was
* validated successfully; <code>false</code> otherwise
* @param validateContext the validating context
* @throws NullPointerException if <code>validateContext</code> is
* <code>null</code>
* @throws XMLSignatureException if an unexpected exception occurs while
* validating the signature
*/
boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException;
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: TransformService.java,v 1.6.4.1 2005/09/15 12:42:11 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Provider.Service;
import java.security.Security;
import java.util.*;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
/** {@collect.stats}
* A Service Provider Interface for transform and canonicalization algorithms.
*
* <p>Each instance of <code>TransformService</code> supports a specific
* transform or canonicalization algorithm and XML mechanism type. To create a
* <code>TransformService</code>, call one of the static
* {@link #getInstance getInstance} methods, passing in the algorithm URI and
* XML mechanism type desired, for example:
*
* <blockquote><code>
* TransformService ts = TransformService.getInstance(Transform.XPATH2, "DOM");
* </code></blockquote>
*
* <p><code>TransformService</code> implementations are registered and loaded
* using the {@link java.security.Provider} mechanism. Each
* <code>TransformService</code> service provider implementation should include
* a <code>MechanismType</code> service attribute that identifies the XML
* mechanism type that it supports. If the attribute is not specified,
* "DOM" is assumed. For example, a service provider that supports the
* XPath Filter 2 Transform and DOM mechanism would be specified in the
* <code>Provider</code> subclass as:
* <pre>
* put("TransformService." + Transform.XPATH2,
* "org.example.XPath2TransformService");
* put("TransformService." + Transform.XPATH2 + " MechanismType", "DOM");
* </pre>
* <code>TransformService</code> implementations that support the DOM
* mechanism type must abide by the DOM interoperability requirements defined
* in the
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
* DOM Mechanism Requirements</a> section of the API overview. See the
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of standard
* mechanism types.
* <p>
* Once a <code>TransformService</code> has been created, it can be used
* to process <code>Transform</code> or <code>CanonicalizationMethod</code>
* objects. If the <code>Transform</code> or <code>CanonicalizationMethod</code>
* exists in XML form (for example, when validating an existing
* <code>XMLSignature</code>), the {@link #init(XMLStructure, XMLCryptoContext)}
* method must be first called to initialize the transform and provide document
* context (even if there are no parameters). Alternatively, if the
* <code>Transform</code> or <code>CanonicalizationMethod</code> is being
* created from scratch, the {@link #init(TransformParameterSpec)} method
* is called to initialize the transform with parameters and the
* {@link #marshalParams marshalParams} method is called to marshal the
* parameters to XML and provide the transform with document context. Finally,
* the {@link #transform transform} method is called to perform the
* transformation.
* <p>
* <b>Concurrent Access</b>
* <p>The static methods of this class are guaranteed to be thread-safe.
* Multiple threads may concurrently invoke the static methods defined in this
* class with no ill effects.
*
* <p>However, this is not true for the non-static methods defined by this
* class. Unless otherwise documented by a specific provider, threads that
* need to access a single <code>TransformService</code> instance
* concurrently should synchronize amongst themselves and provide the
* necessary locking. Multiple threads each manipulating a different
* <code>TransformService</code> instance need not synchronize.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public abstract class TransformService implements Transform {
private String algorithm;
private String mechanism;
private Provider provider;
/** {@collect.stats}
* Default constructor, for invocation by subclasses.
*/
protected TransformService() {}
/** {@collect.stats}
* Returns a <code>TransformService</code> that supports the specified
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
* (ex: DOM).
*
* <p>This method uses the standard JCA provider lookup mechanism to
* locate and instantiate a <code>TransformService</code> implementation
* of the desired algorithm and <code>MechanismType</code> service
* attribute. It traverses the list of registered security
* <code>Provider</code>s, starting with the most preferred
* <code>Provider</code>. A new <code>TransformService</code> object
* from the first <code>Provider</code> that supports the specified
* algorithm and mechanism type is returned.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param algorithm the URI of the algorithm
* @param mechanismType the type of the XML processing mechanism and
* representation
* @return a new <code>TransformService</code>
* @throws NullPointerException if <code>algorithm</code> or
* <code>mechanismType</code> is <code>null</code>
* @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
* <code>TransformService</code> implementation for the specified
* algorithm and mechanism type
* @see Provider
*/
public static TransformService getInstance
(String algorithm, String mechanismType)
throws NoSuchAlgorithmException {
if (mechanismType == null || algorithm == null) {
throw new NullPointerException();
}
boolean dom = false;
if (mechanismType.equals("DOM")) {
dom = true;
}
List services = GetInstance.getServices("TransformService", algorithm);
for (Iterator t = services.iterator(); t.hasNext(); ) {
Service s = (Service)t.next();
String value = s.getAttribute("MechanismType");
if ((value == null && dom) ||
(value != null && value.equals(mechanismType))) {
Instance instance = GetInstance.getInstance(s, null);
TransformService ts = (TransformService) instance.impl;
ts.algorithm = algorithm;
ts.mechanism = mechanismType;
ts.provider = instance.provider;
return ts;
}
}
throw new NoSuchAlgorithmException
(algorithm + " algorithm and " + mechanismType
+ " mechanism not available");
}
/** {@collect.stats}
* Returns a <code>TransformService</code> that supports the specified
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
* (ex: DOM) as supplied by the specified provider. Note that the specified
* <code>Provider</code> object does not have to be registered in the
* provider list.
*
* @param algorithm the URI of the algorithm
* @param mechanismType the type of the XML processing mechanism and
* representation
* @param provider the <code>Provider</code> object
* @return a new <code>TransformService</code>
* @throws NullPointerException if <code>provider</code>,
* <code>algorithm</code>, or <code>mechanismType</code> is
* <code>null</code>
* @throws NoSuchAlgorithmException if a <code>TransformService</code>
* implementation for the specified algorithm and mechanism type is not
* available from the specified <code>Provider</code> object
* @see Provider
*/
public static TransformService getInstance
(String algorithm, String mechanismType, Provider provider)
throws NoSuchAlgorithmException {
if (mechanismType == null || algorithm == null || provider == null) {
throw new NullPointerException();
}
boolean dom = false;
if (mechanismType.equals("DOM")) {
dom = true;
}
Service s = GetInstance.getService
("TransformService", algorithm, provider);
String value = s.getAttribute("MechanismType");
if ((value == null && dom) ||
(value != null && value.equals(mechanismType))) {
Instance instance = GetInstance.getInstance(s, null);
TransformService ts = (TransformService) instance.impl;
ts.algorithm = algorithm;
ts.mechanism = mechanismType;
ts.provider = instance.provider;
return ts;
}
throw new NoSuchAlgorithmException
(algorithm + " algorithm and " + mechanismType
+ " mechanism not available");
}
/** {@collect.stats}
* Returns a <code>TransformService</code> that supports the specified
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
* (ex: DOM) as supplied by the specified provider. The specified provider
* must be registered in the security provider list.
*
* <p>Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param algorithm the URI of the algorithm
* @param mechanismType the type of the XML processing mechanism and
* representation
* @param provider the string name of the provider
* @return a new <code>TransformService</code>
* @throws NoSuchProviderException if the specified provider is not
* registered in the security provider list
* @throws NullPointerException if <code>provider</code>,
* <code>mechanismType</code>, or <code>algorithm</code> is
* <code>null</code>
* @throws NoSuchAlgorithmException if a <code>TransformService</code>
* implementation for the specified algorithm and mechanism type is not
* available from the specified provider
* @see Provider
*/
public static TransformService getInstance
(String algorithm, String mechanismType, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
if (mechanismType == null || algorithm == null || provider == null) {
throw new NullPointerException();
} else if (provider.length() == 0) {
throw new NoSuchProviderException();
}
boolean dom = false;
if (mechanismType.equals("DOM")) {
dom = true;
}
Service s = GetInstance.getService
("TransformService", algorithm, provider);
String value = s.getAttribute("MechanismType");
if ((value == null && dom) ||
(value != null && value.equals(mechanismType))) {
Instance instance = GetInstance.getInstance(s, null);
TransformService ts = (TransformService) instance.impl;
ts.algorithm = algorithm;
ts.mechanism = mechanismType;
ts.provider = instance.provider;
return ts;
}
throw new NoSuchAlgorithmException
(algorithm + " algorithm and " + mechanismType
+ " mechanism not available");
}
private static class MechanismMapEntry implements Map.Entry {
private final String mechanism;
private final String algorithm;
private final String key;
MechanismMapEntry(String algorithm, String mechanism) {
this.algorithm = algorithm;
this.mechanism = mechanism;
this.key = "TransformService." + algorithm + " MechanismType";
}
public boolean equals(Object o) {
if (!(o instanceof Map.Entry)) {
return false;
}
Map.Entry e = (Map.Entry) o;
return (getKey()==null ?
e.getKey()==null : getKey().equals(e.getKey())) &&
(getValue()==null ?
e.getValue()==null : getValue().equals(e.getValue()));
}
public Object getKey() {
return key;
}
public Object getValue() {
return mechanism;
}
public Object setValue(Object value) {
throw new UnsupportedOperationException();
}
public int hashCode() {
return (getKey()==null ? 0 : getKey().hashCode()) ^
(getValue()==null ? 0 : getValue().hashCode());
}
}
/** {@collect.stats}
* Returns the mechanism type supported by this <code>TransformService</code>.
*
* @return the mechanism type
*/
public final String getMechanismType() {
return mechanism;
}
/** {@collect.stats}
* Returns the URI of the algorithm supported by this
* <code>TransformService</code>.
*
* @return the algorithm URI
*/
public final String getAlgorithm() {
return algorithm;
}
/** {@collect.stats}
* Returns the provider of this <code>TransformService</code>.
*
* @return the provider
*/
public final Provider getProvider() {
return provider;
}
/** {@collect.stats}
* Initializes this <code>TransformService</code> with the specified
* parameters.
*
* <p>If the parameters exist in XML form, the
* {@link #init(XMLStructure, XMLCryptoContext)} method should be used to
* initialize the <code>TransformService</code>.
*
* @param params the algorithm parameters (may be <code>null</code> if
* not required or optional)
* @throws InvalidAlgorithmParameterException if the specified parameters
* are invalid for this algorithm
*/
public abstract void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException;
/** {@collect.stats}
* Marshals the algorithm-specific parameters. If there are no parameters
* to be marshalled, this method returns without throwing an exception.
*
* @param parent a mechanism-specific structure containing the parent
* node that the marshalled parameters should be appended to
* @param context the <code>XMLCryptoContext</code> containing
* additional context (may be <code>null</code> if not applicable)
* @throws ClassCastException if the type of <code>parent</code> or
* <code>context</code> is not compatible with this
* <code>TransformService</code>
* @throws NullPointerException if <code>parent</code> is <code>null</code>
* @throws MarshalException if the parameters cannot be marshalled
*/
public abstract void marshalParams
(XMLStructure parent, XMLCryptoContext context)
throws MarshalException;
/** {@collect.stats}
* Initializes this <code>TransformService</code> with the specified
* parameters and document context.
*
* @param parent a mechanism-specific structure containing the parent
* structure
* @param context the <code>XMLCryptoContext</code> containing
* additional context (may be <code>null</code> if not applicable)
* @throws ClassCastException if the type of <code>parent</code> or
* <code>context</code> is not compatible with this
* <code>TransformService</code>
* @throws NullPointerException if <code>parent</code> is <code>null</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are invalid for this algorithm
*/
public abstract void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLValidateContext.java,v 1.8 2005/05/10 16:03:49 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.XMLCryptoContext;
/** {@collect.stats}
* Contains context information for validating XML Signatures. This interface
* is primarily intended for type-safety.
*
* <p>Note that <code>XMLValidateContext</code> instances can contain
* information and state specific to the XML signature structure it is
* used with. The results are unpredictable if an
* <code>XMLValidateContext</code> is used with different signature structures
* (for example, you should not use the same <code>XMLValidateContext</code>
* instance to validate two different {@link XMLSignature} objects).
* <p>
* <b><a name="Supported Properties"></a>Supported Properties</b>
* <p>The following properties can be set by an application using the
* {@link #setProperty setProperty} method.
* <ul>
* <li><code>javax.xml.crypto.dsig.cacheReference</code>: value must be a
* {@link Boolean}. This property controls whether or not the
* {@link Reference#validate Reference.validate} method will cache the
* dereferenced content and pre-digested input for subsequent retrieval via
* the {@link Reference#getDereferencedData Reference.getDereferencedData}
* and {@link Reference#getDigestInputStream
* Reference.getDigestInputStream} methods. The default value if not
* specified is <code>Boolean.FALSE</code>.
* </ul>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignature#validate(XMLValidateContext)
* @see Reference#validate(XMLValidateContext)
*/
public interface XMLValidateContext extends XMLCryptoContext {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: CanonicalizationMethod.java,v 1.6 2005/05/10 16:03:45 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.security.spec.AlgorithmParameterSpec;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
/** {@collect.stats}
* A representation of the XML <code>CanonicalizationMethod</code>
* element as defined in the
* <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>. The XML
* Schema Definition is defined as:
* <p>
* <pre>
* <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
* <complexType name="CanonicalizationMethodType" mixed="true">
* <sequence>
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
* <!-- (0,unbounded) elements from (1,1) namespace -->
* </sequence>
* <attribute name="Algorithm" type="anyURI" use="required"/>
* </complexType>
* </pre>
*
* A <code>CanonicalizationMethod</code> instance may be created by invoking
* the {@link XMLSignatureFactory#newCanonicalizationMethod
* newCanonicalizationMethod} method of the {@link XMLSignatureFactory} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newCanonicalizationMethod(String, C14NMethodParameterSpec)
*/
public interface CanonicalizationMethod extends Transform {
/** {@collect.stats}
* The <a href="http://www.w3.org/TR/2001/REC-xml-c14n-20010315">Canonical
* XML (without comments)</a> canonicalization method algorithm URI.
*/
final static String INCLUSIVE =
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
/** {@collect.stats}
* The
* <a href="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments">
* Canonical XML with comments</a> canonicalization method algorithm URI.
*/
final static String INCLUSIVE_WITH_COMMENTS =
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
/** {@collect.stats}
* The <a href="http://www.w3.org/2001/10/xml-exc-c14n#">Exclusive
* Canonical XML (without comments)</a> canonicalization method algorithm
* URI.
*/
final static String EXCLUSIVE =
"http://www.w3.org/2001/10/xml-exc-c14n#";
/** {@collect.stats}
* The <a href="http://www.w3.org/2001/10/xml-exc-c14n#WithComments">
* Exclusive Canonical XML with comments</a> canonicalization method
* algorithm URI.
*/
final static String EXCLUSIVE_WITH_COMMENTS =
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
/** {@collect.stats}
* Returns the algorithm-specific input parameters associated with this
* <code>CanonicalizationMethod</code>.
*
* <p>The returned parameters can be typecast to a
* {@link C14NMethodParameterSpec} object.
*
* @return the algorithm-specific input parameters (may be
* <code>null</code> if not specified)
*/
AlgorithmParameterSpec getParameterSpec();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLSignatureException.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.io.PrintStream;
import java.io.PrintWriter;
/** {@collect.stats}
* Indicates an exceptional condition that occured during the XML
* signature generation or validation process.
*
* <p>An <code>XMLSignatureException</code> can contain a cause: another
* throwable that caused this <code>XMLSignatureException</code> to get thrown.
*
* @since 1.6
*/
public class XMLSignatureException extends Exception {
private static final long serialVersionUID = -3438102491013869995L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or null if this
* exception was not caused by another throwable or if the causative
* throwable is unknown.
*
* @serial
*/
private Throwable cause;
/** {@collect.stats}
* Constructs a new <code>XMLSignatureException</code> with
* <code>null</code> as its detail message.
*/
public XMLSignatureException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>XMLSignatureException</code> with the specified
* detail message.
*
* @param message the detail message
*/
public XMLSignatureException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>XMLSignatureException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public XMLSignatureException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>XMLSignatureException</code> with the specified
* cause and a detail message of
* <code>(cause==null ? null : cause.toString())</code>
* (which typically contains the class and detail message of
* <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public XMLSignatureException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the cause of this <code>XMLSignatureException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>XMLSignatureException</code> to get thrown.)
*
* @return the cause of this <code>XMLSignatureException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>XMLSignatureException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
if (cause != null) {
cause.printStackTrace();
}
}
/** {@collect.stats}
* Prints this <code>XMLSignatureException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
if (cause != null) {
cause.printStackTrace(s);
}
}
/** {@collect.stats}
* Prints this <code>XMLSignatureException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (cause != null) {
cause.printStackTrace(s);
}
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLSignatureFactory.java,v 1.14 2005/09/15 14:29:01 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.Data;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.NoSuchMechanismException;
import javax.xml.crypto.URIDereferencer;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMStructure;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import javax.xml.crypto.dsig.spec.*;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.dom.DOMSignContext;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
import java.util.List;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
/** {@collect.stats}
* A factory for creating {@link XMLSignature} objects from scratch or
* for unmarshalling an <code>XMLSignature</code> object from a corresponding
* XML representation.
*
* <h2>XMLSignatureFactory Type</h2>
*
* <p>Each instance of <code>XMLSignatureFactory</code> supports a specific
* XML mechanism type. To create an <code>XMLSignatureFactory</code>, call one
* of the static {@link #getInstance getInstance} methods, passing in the XML
* mechanism type desired, for example:
*
* <blockquote><code>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* </code></blockquote>
*
* <p>The objects that this factory produces will be based
* on DOM and abide by the DOM interoperability requirements as defined in the
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
* DOM Mechanism Requirements</a> section of the API overview. See the
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of standard
* mechanism types.
*
* <p><code>XMLSignatureFactory</code> implementations are registered and loaded
* using the {@link java.security.Provider} mechanism.
* For example, a service provider that supports the
* DOM mechanism would be specified in the <code>Provider</code> subclass as:
* <pre>
* put("XMLSignatureFactory.DOM", "org.example.DOMXMLSignatureFactory");
* </pre>
*
* <p>An implementation MUST minimally support the default mechanism type: DOM.
*
* <p>Note that a caller must use the same <code>XMLSignatureFactory</code>
* instance to create the <code>XMLStructure</code>s of a particular
* <code>XMLSignature</code> that is to be generated. The behavior is
* undefined if <code>XMLStructure</code>s from different providers or
* different mechanism types are used together.
*
* <p>Also, the <code>XMLStructure</code>s that are created by this factory
* may contain state specific to the <code>XMLSignature</code> and are not
* intended to be reusable.
*
* <h2>Creating XMLSignatures from scratch</h2>
*
* <p>Once the <code>XMLSignatureFactory</code> has been created, objects
* can be instantiated by calling the appropriate method. For example, a
* {@link Reference} instance may be created by invoking one of the
* {@link #newReference newReference} methods.
*
* <h2>Unmarshalling XMLSignatures from XML</h2>
*
* <p>Alternatively, an <code>XMLSignature</code> may be created from an
* existing XML representation by invoking the {@link #unmarshalXMLSignature
* unmarshalXMLSignature} method and passing it a mechanism-specific
* {@link XMLValidateContext} instance containing the XML content:
*
* <pre>
* DOMValidateContext context = new DOMValidateContext(key, signatureElement);
* XMLSignature signature = factory.unmarshalXMLSignature(context);
* </pre>
*
* Each <code>XMLSignatureFactory</code> must support the required
* <code>XMLValidateContext</code> types for that factory type, but may support
* others. A DOM <code>XMLSignatureFactory</code> must support {@link
* DOMValidateContext} objects.
*
* <h2>Signing and marshalling XMLSignatures to XML</h2>
*
* Each <code>XMLSignature</code> created by the factory can also be
* marshalled to an XML representation and signed, by invoking the
* {@link XMLSignature#sign sign} method of the
* {@link XMLSignature} object and passing it a mechanism-specific
* {@link XMLSignContext} object containing the signing key and
* marshalling parameters (see {@link DOMSignContext}).
* For example:
*
* <pre>
* DOMSignContext context = new DOMSignContext(privateKey, document);
* signature.sign(context);
* </pre>
*
* <b>Concurrent Access</b>
* <p>The static methods of this class are guaranteed to be thread-safe.
* Multiple threads may concurrently invoke the static methods defined in this
* class with no ill effects.
*
* <p>However, this is not true for the non-static methods defined by this
* class. Unless otherwise documented by a specific provider, threads that
* need to access a single <code>XMLSignatureFactory</code> instance
* concurrently should synchronize amongst themselves and provide the
* necessary locking. Multiple threads each manipulating a different
* <code>XMLSignatureFactory</code> instance need not synchronize.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public abstract class XMLSignatureFactory {
private String mechanismType;
private Provider provider;
/** {@collect.stats}
* Default constructor, for invocation by subclasses.
*/
protected XMLSignatureFactory() {}
/** {@collect.stats}
* Returns an <code>XMLSignatureFactory</code> that supports the
* specified XML processing mechanism and representation type (ex: "DOM").
*
* <p>This method uses the standard JCA provider lookup mechanism to
* locate and instantiate an <code>XMLSignatureFactory</code>
* implementation of the desired mechanism type. It traverses the list of
* registered security <code>Provider</code>s, starting with the most
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
* object from the first <code>Provider</code> that supports the specified
* mechanism is returned.
*
* <p>Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @return a new <code>XMLSignatureFactory</code>
* @throws NullPointerException if <code>mechanismType</code> is
* <code>null</code>
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
* <code>XMLSignatureFactory</code> implementation for the specified
* mechanism
* @see Provider
*/
public static XMLSignatureFactory getInstance(String mechanismType) {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
}
Instance instance;
try {
instance = GetInstance.getInstance
("XMLSignatureFactory", null, mechanismType);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns an <code>XMLSignatureFactory</code> that supports the
* requested XML processing mechanism and representation type (ex: "DOM"),
* as supplied by the specified provider. Note that the specified
* <code>Provider</code> object does not have to be registered in the
* provider list.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @param provider the <code>Provider</code> object
* @return a new <code>XMLSignatureFactory</code>
* @throws NullPointerException if <code>provider</code> or
* <code>mechanismType</code> is <code>null</code>
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
* implementation for the specified mechanism is not available
* from the specified <code>Provider</code> object
* @see Provider
*/
public static XMLSignatureFactory getInstance(String mechanismType,
Provider provider) {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
} else if (provider == null) {
throw new NullPointerException("provider cannot be null");
}
Instance instance;
try {
instance = GetInstance.getInstance
("XMLSignatureFactory", null, mechanismType, provider);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns an <code>XMLSignatureFactory</code> that supports the
* requested XML processing mechanism and representation type (ex: "DOM"),
* as supplied by the specified provider. The specified provider must be
* registered in the security provider list.
*
* <p>Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @param provider the string name of the provider
* @return a new <code>XMLSignatureFactory</code>
* @throws NoSuchProviderException if the specified provider is not
* registered in the security provider list
* @throws NullPointerException if <code>provider</code> or
* <code>mechanismType</code> is <code>null</code>
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
* implementation for the specified mechanism is not
* available from the specified provider
* @see Provider
*/
public static XMLSignatureFactory getInstance(String mechanismType,
String provider) throws NoSuchProviderException {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
} else if (provider == null) {
throw new NullPointerException("provider cannot be null");
} else if (provider.length() == 0) {
throw new NoSuchProviderException();
}
Instance instance;
try {
instance = GetInstance.getInstance
("XMLSignatureFactory", null, mechanismType, provider);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns an <code>XMLSignatureFactory</code> that supports the
* default XML processing mechanism and representation type ("DOM").
*
* <p>This method uses the standard JCA provider lookup mechanism to
* locate and instantiate an <code>XMLSignatureFactory</code>
* implementation of the default mechanism type. It traverses the list of
* registered security <code>Provider</code>s, starting with the most
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
* object from the first <code>Provider</code> that supports the DOM
* mechanism is returned.
*
* <p>Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @return a new <code>XMLSignatureFactory</code>
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
* <code>XMLSignatureFactory</code> implementation for the DOM
* mechanism
* @see Provider
*/
public static XMLSignatureFactory getInstance() {
return getInstance("DOM");
}
/** {@collect.stats}
* Returns the type of the XML processing mechanism and representation
* supported by this <code>XMLSignatureFactory</code> (ex: "DOM").
*
* @return the XML processing mechanism type supported by this
* <code>XMLSignatureFactory</code>
*/
public final String getMechanismType() {
return mechanismType;
}
/** {@collect.stats}
* Returns the provider of this <code>XMLSignatureFactory</code>.
*
* @return the provider of this <code>XMLSignatureFactory</code>
*/
public final Provider getProvider() {
return provider;
}
/** {@collect.stats}
* Creates an <code>XMLSignature</code> and initializes it with the contents
* of the specified <code>SignedInfo</code> and <code>KeyInfo</code>
* objects.
*
* @param si the signed info
* @param ki the key info (may be <code>null</code>)
* @return an <code>XMLSignature</code>
* @throws NullPointerException if <code>si</code> is <code>null</code>
*/
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki);
/** {@collect.stats}
* Creates an <code>XMLSignature</code> and initializes it with the
* specified parameters.
*
* @param si the signed info
* @param ki the key info (may be <code>null</code>)
* @param objects a list of {@link XMLObject}s (may be empty or
* <code>null</code>)
* @param id the Id (may be <code>null</code>)
* @param signatureValueId the SignatureValue Id (may be <code>null</code>)
* @return an <code>XMLSignature</code>
* @throws NullPointerException if <code>si</code> is <code>null</code>
* @throws ClassCastException if any of the <code>objects</code> are not of
* type <code>XMLObject</code>
*/
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
List objects, String id, String signatureValueId);
/** {@collect.stats}
* Creates a <code>Reference</code> with the specified URI and digest
* method.
*
* @param uri the reference URI (may be <code>null</code>)
* @param dm the digest method
* @return a <code>Reference</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant
* @throws NullPointerException if <code>dm</code> is <code>null</code>
*/
public abstract Reference newReference(String uri, DigestMethod dm);
/** {@collect.stats}
* Creates a <code>Reference</code> with the specified parameters.
*
* @param uri the reference URI (may be <code>null</code>)
* @param dm the digest method
* @param transforms a list of {@link Transform}s. The list is defensively
* copied to protect against subsequent modification. May be
* <code>null</code> or empty.
* @param type the reference type, as a URI (may be <code>null</code>)
* @param id the reference ID (may be <code>null</code>)
* @return a <code>Reference</code>
* @throws ClassCastException if any of the <code>transforms</code> are
* not of type <code>Transform</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant
* @throws NullPointerException if <code>dm</code> is <code>null</code>
*/
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id);
/** {@collect.stats}
* Creates a <code>Reference</code> with the specified parameters and
* pre-calculated digest value.
*
* <p>This method is useful when the digest value of a
* <code>Reference</code> has been previously computed. See for example,
* the
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
* OASIS-DSS (Digital Signature Services)</a> specification.
*
* @param uri the reference URI (may be <code>null</code>)
* @param dm the digest method
* @param transforms a list of {@link Transform}s. The list is defensively
* copied to protect against subsequent modification. May be
* <code>null</code> or empty.
* @param type the reference type, as a URI (may be <code>null</code>)
* @param id the reference ID (may be <code>null</code>)
* @param digestValue the digest value. The array is cloned to protect
* against subsequent modification.
* @return a <code>Reference</code>
* @throws ClassCastException if any of the <code>transforms</code> are
* not of type <code>Transform</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant
* @throws NullPointerException if <code>dm</code> or
* <code>digestValue</code> is <code>null</code>
*/
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id, byte[] digestValue);
/** {@collect.stats}
* Creates a <code>Reference</code> with the specified parameters.
*
* <p>This method is useful when a list of transforms have already been
* applied to the <code>Reference</code>. See for example,
* the
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
* OASIS-DSS (Digital Signature Services)</a> specification.
*
* <p>When an <code>XMLSignature</code> containing this reference is
* generated, the specified <code>transforms</code> (if non-null) are
* applied to the specified <code>result</code>. The
* <code>Transforms</code> element of the resulting <code>Reference</code>
* element is set to the concatenation of the
* <code>appliedTransforms</code> and <code>transforms</code>.
*
* @param uri the reference URI (may be <code>null</code>)
* @param dm the digest method
* @param appliedTransforms a list of {@link Transform}s that have
* already been applied. The list is defensively
* copied to protect against subsequent modification. The list must
* contain at least one entry.
* @param result the result of processing the sequence of
* <code>appliedTransforms</code>
* @param transforms a list of {@link Transform}s that are to be applied
* when generating the signature. The list is defensively copied to
* protect against subsequent modification. May be <code>null</code>
* or empty.
* @param type the reference type, as a URI (may be <code>null</code>)
* @param id the reference ID (may be <code>null</code>)
* @return a <code>Reference</code>
* @throws ClassCastException if any of the transforms (in either list)
* are not of type <code>Transform</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant or <code>appliedTransforms</code> is empty
* @throws NullPointerException if <code>dm</code>,
* <code>appliedTransforms</code> or <code>result</code> is
* <code>null</code>
*/
public abstract Reference newReference(String uri, DigestMethod dm,
List appliedTransforms, Data result, List transforms, String type,
String id);
/** {@collect.stats}
* Creates a <code>SignedInfo</code> with the specified canonicalization
* and signature methods, and list of one or more references.
*
* @param cm the canonicalization method
* @param sm the signature method
* @param references a list of one or more {@link Reference}s. The list is
* defensively copied to protect against subsequent modification.
* @return a <code>SignedInfo</code>
* @throws ClassCastException if any of the references are not of
* type <code>Reference</code>
* @throws IllegalArgumentException if <code>references</code> is empty
* @throws NullPointerException if any of the parameters
* are <code>null</code>
*/
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references);
/** {@collect.stats}
* Creates a <code>SignedInfo</code> with the specified parameters.
*
* @param cm the canonicalization method
* @param sm the signature method
* @param references a list of one or more {@link Reference}s. The list is
* defensively copied to protect against subsequent modification.
* @param id the id (may be <code>null</code>)
* @return a <code>SignedInfo</code>
* @throws ClassCastException if any of the references are not of
* type <code>Reference</code>
* @throws IllegalArgumentException if <code>references</code> is empty
* @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
* <code>references</code> are <code>null</code>
*/
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references, String id);
// Object factory methods
/** {@collect.stats}
* Creates an <code>XMLObject</code> from the specified parameters.
*
* @param content a list of {@link XMLStructure}s. The list
* is defensively copied to protect against subsequent modification.
* May be <code>null</code> or empty.
* @param id the Id (may be <code>null</code>)
* @param mimeType the mime type (may be <code>null</code>)
* @param encoding the encoding (may be <code>null</code>)
* @return an <code>XMLObject</code>
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
public abstract XMLObject newXMLObject(List content, String id,
String mimeType, String encoding);
/** {@collect.stats}
* Creates a <code>Manifest</code> containing the specified
* list of {@link Reference}s.
*
* @param references a list of one or more <code>Reference</code>s. The list
* is defensively copied to protect against subsequent modification.
* @return a <code>Manifest</code>
* @throws NullPointerException if <code>references</code> is
* <code>null</code>
* @throws IllegalArgumentException if <code>references</code> is empty
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
public abstract Manifest newManifest(List references);
/** {@collect.stats}
* Creates a <code>Manifest</code> containing the specified
* list of {@link Reference}s and optional id.
*
* @param references a list of one or more <code>Reference</code>s. The list
* is defensively copied to protect against subsequent modification.
* @param id the id (may be <code>null</code>)
* @return a <code>Manifest</code>
* @throws NullPointerException if <code>references</code> is
* <code>null</code>
* @throws IllegalArgumentException if <code>references</code> is empty
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
public abstract Manifest newManifest(List references, String id);
/** {@collect.stats}
* Creates a <code>SignatureProperty</code> containing the specified
* list of {@link XMLStructure}s, target URI and optional id.
*
* @param content a list of one or more <code>XMLStructure</code>s. The list
* is defensively copied to protect against subsequent modification.
* @param target the target URI of the Signature that this property applies
* to
* @param id the id (may be <code>null</code>)
* @return a <code>SignatureProperty</code>
* @throws NullPointerException if <code>content</code> or
* <code>target</code> is <code>null</code>
* @throws IllegalArgumentException if <code>content</code> is empty
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
public abstract SignatureProperty newSignatureProperty
(List content, String target, String id);
/** {@collect.stats}
* Creates a <code>SignatureProperties</code> containing the specified
* list of {@link SignatureProperty}s and optional id.
*
* @param properties a list of one or more <code>SignatureProperty</code>s.
* The list is defensively copied to protect against subsequent
* modification.
* @param id the id (may be <code>null</code>)
* @return a <code>SignatureProperties</code>
* @throws NullPointerException if <code>properties</code>
* is <code>null</code>
* @throws IllegalArgumentException if <code>properties</code> is empty
* @throws ClassCastException if <code>properties</code> contains any
* entries that are not of type {@link SignatureProperty}
*/
public abstract SignatureProperties newSignatureProperties
(List properties, String id);
// Algorithm factory methods
/** {@collect.stats}
* Creates a <code>DigestMethod</code> for the specified algorithm URI
* and parameters.
*
* @param algorithm the URI identifying the digest algorithm
* @param params algorithm-specific digest parameters (may be
* <code>null</code>)
* @return the <code>DigestMethod</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract DigestMethod newDigestMethod(String algorithm,
DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException;
/** {@collect.stats}
* Creates a <code>SignatureMethod</code> for the specified algorithm URI
* and parameters.
*
* @param algorithm the URI identifying the signature algorithm
* @param params algorithm-specific signature parameters (may be
* <code>null</code>)
* @return the <code>SignatureMethod</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract SignatureMethod newSignatureMethod(String algorithm,
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException;
/** {@collect.stats}
* Creates a <code>Transform</code> for the specified algorithm URI
* and parameters.
*
* @param algorithm the URI identifying the transform algorithm
* @param params algorithm-specific transform parameters (may be
* <code>null</code>)
* @return the <code>Transform</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract Transform newTransform(String algorithm,
TransformParameterSpec params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException;
/** {@collect.stats}
* Creates a <code>Transform</code> for the specified algorithm URI
* and parameters. The parameters are specified as a mechanism-specific
* <code>XMLStructure</code> (ex: {@link DOMStructure}). This method is
* useful when the parameters are in XML form or there is no standard
* class for specifying the parameters.
*
* @param algorithm the URI identifying the transform algorithm
* @param params a mechanism-specific XML structure from which to
* unmarshal the parameters from (may be <code>null</code> if
* not required or optional)
* @return the <code>Transform</code>
* @throws ClassCastException if the type of <code>params</code> is
* inappropriate for this <code>XMLSignatureFactory</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract Transform newTransform(String algorithm,
XMLStructure params) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException;
/** {@collect.stats}
* Creates a <code>CanonicalizationMethod</code> for the specified
* algorithm URI and parameters.
*
* @param algorithm the URI identifying the canonicalization algorithm
* @param params algorithm-specific canonicalization parameters (may be
* <code>null</code>)
* @return the <code>CanonicalizationMethod</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract CanonicalizationMethod newCanonicalizationMethod(
String algorithm, C14NMethodParameterSpec params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
/** {@collect.stats}
* Creates a <code>CanonicalizationMethod</code> for the specified
* algorithm URI and parameters. The parameters are specified as a
* mechanism-specific <code>XMLStructure</code> (ex: {@link DOMStructure}).
* This method is useful when the parameters are in XML form or there is
* no standard class for specifying the parameters.
*
* @param algorithm the URI identifying the canonicalization algorithm
* @param params a mechanism-specific XML structure from which to
* unmarshal the parameters from (may be <code>null</code> if
* not required or optional)
* @return the <code>CanonicalizationMethod</code>
* @throws ClassCastException if the type of <code>params</code> is
* inappropriate for this <code>XMLSignatureFactory</code>
* @throws InvalidAlgorithmParameterException if the specified parameters
* are inappropriate for the requested algorithm
* @throws NoSuchAlgorithmException if an implementation of the
* specified algorithm cannot be found
* @throws NullPointerException if <code>algorithm</code> is
* <code>null</code>
*/
public abstract CanonicalizationMethod newCanonicalizationMethod(
String algorithm, XMLStructure params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
/** {@collect.stats}
* Returns a <code>KeyInfoFactory</code> that creates <code>KeyInfo</code>
* objects. The returned <code>KeyInfoFactory</code> has the same
* mechanism type and provider as this <code>XMLSignatureFactory</code>.
*
* @return a <code>KeyInfoFactory</code>
* @throws NoSuchMechanismException if a <code>KeyFactory</code>
* implementation with the same mechanism type and provider
* is not available
*/
public final KeyInfoFactory getKeyInfoFactory() {
return KeyInfoFactory.getInstance(getMechanismType(), getProvider());
}
/** {@collect.stats}
* Unmarshals a new <code>XMLSignature</code> instance from a
* mechanism-specific <code>XMLValidateContext</code> instance.
*
* @param context a mechanism-specific context from which to unmarshal the
* signature from
* @return the <code>XMLSignature</code>
* @throws NullPointerException if <code>context</code> is
* <code>null</code>
* @throws ClassCastException if the type of <code>context</code> is
* inappropriate for this factory
* @throws MarshalException if an unrecoverable exception occurs
* during unmarshalling
*/
public abstract XMLSignature unmarshalXMLSignature
(XMLValidateContext context) throws MarshalException;
/** {@collect.stats}
* Unmarshals a new <code>XMLSignature</code> instance from a
* mechanism-specific <code>XMLStructure</code> instance.
* This method is useful if you only want to unmarshal (and not
* validate) an <code>XMLSignature</code>.
*
* @param xmlStructure a mechanism-specific XML structure from which to
* unmarshal the signature from
* @return the <code>XMLSignature</code>
* @throws NullPointerException if <code>xmlStructure</code> is
* <code>null</code>
* @throws ClassCastException if the type of <code>xmlStructure</code> is
* inappropriate for this factory
* @throws MarshalException if an unrecoverable exception occurs
* during unmarshalling
*/
public abstract XMLSignature unmarshalXMLSignature
(XMLStructure xmlStructure) throws MarshalException;
/** {@collect.stats}
* Indicates whether a specified feature is supported.
*
* @param feature the feature name (as an absolute URI)
* @return <code>true</code> if the specified feature is supported,
* <code>false</code> otherwise
* @throws NullPointerException if <code>feature</code> is <code>null</code>
*/
public abstract boolean isFeatureSupported(String feature);
/** {@collect.stats}
* Returns a reference to the <code>URIDereferencer</code> that is used by
* default to dereference URIs in {@link Reference} objects.
*
* @return a reference to the default <code>URIDereferencer</code> (never
* <code>null</code>)
*/
public abstract URIDereferencer getURIDereferencer();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: TransformException.java,v 1.3 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.io.PrintStream;
import java.io.PrintWriter;
/** {@collect.stats}
* Indicates an exceptional condition that occured while executing a
* transform algorithm.
*
* <p>A <code>TransformException</code> can contain a cause: another
* throwable that caused this <code>TransformException</code> to get thrown.
*
* @see Transform#transform
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public class TransformException extends Exception {
private static final long serialVersionUID = 5082634801360427800L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or null if this
* exception was not caused by another throwable or if the causative
* throwable is unknown.
*
* @serial
*/
private Throwable cause;
/** {@collect.stats}
* Constructs a new <code>TransformException</code> with
* <code>null</code> as its detail message.
*/
public TransformException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>TransformException</code> with the specified
* detail message.
*
* @param message the detail message
*/
public TransformException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>TransformException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public TransformException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>TransformException</code> with the specified
* cause and a detail message of
* <code>(cause==null ? null : cause.toString())</code>
* (which typically contains the class and detail message of
* <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public TransformException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the cause of this <code>TransformException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>TransformException</code> to get thrown.)
*
* @return the cause of this <code>TransformException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>TransformException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
if (cause != null) {
cause.printStackTrace();
}
}
/** {@collect.stats}
* Prints this <code>TransformException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
if (cause != null) {
cause.printStackTrace(s);
}
}
/** {@collect.stats}
* Prints this <code>TransformException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (cause != null) {
cause.printStackTrace(s);
}
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DigestMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.DigestMethod;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* A specification of algorithm parameters for a {@link DigestMethod}
* algorithm. The purpose of this interface is to group (and provide type
* safety for) all digest method parameter specifications. All digest method
* parameter specifications must implement this interface.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see DigestMethod
*/
public interface DigestMethodParameterSpec extends AlgorithmParameterSpec {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XPathFilterParameterSpec.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.Transform;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
/** {@collect.stats}
* Parameters for the <a href="http://www.w3.org/TR/xmldsig-core/#sec-XPath">
* XPath Filtering Transform Algorithm</a>.
* The parameters include the XPath expression and an optional <code>Map</code>
* of additional namespace prefix mappings. The XML Schema Definition of
* the XPath Filtering transform parameters is defined as:
* <pre><code>
* <element name="XPath" type="string"/>
* </code></pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see Transform
*/
public final class XPathFilterParameterSpec implements TransformParameterSpec {
private String xPath;
private Map nsMap;
/** {@collect.stats}
* Creates an <code>XPathFilterParameterSpec</code> with the specified
* XPath expression.
*
* @param xPath the XPath expression to be evaluated
* @throws NullPointerException if <code>xPath</code> is <code>null</code>
*/
public XPathFilterParameterSpec(String xPath) {
if (xPath == null) {
throw new NullPointerException();
}
this.xPath = xPath;
this.nsMap = Collections.EMPTY_MAP;
}
/** {@collect.stats}
* Creates an <code>XPathFilterParameterSpec</code> with the specified
* XPath expression and namespace map. The map is copied to protect against
* subsequent modification.
*
* @param xPath the XPath expression to be evaluated
* @param namespaceMap the map of namespace prefixes. Each key is a
* namespace prefix <code>String</code> that maps to a corresponding
* namespace URI <code>String</code>.
* @throws NullPointerException if <code>xPath</code> or
* <code>namespaceMap</code> are <code>null</code>
* @throws ClassCastException if any of the map's keys or entries are not
* of type <code>String</code>
*/
public XPathFilterParameterSpec(String xPath, Map namespaceMap) {
if (xPath == null || namespaceMap == null) {
throw new NullPointerException();
}
this.xPath = xPath;
nsMap = new HashMap(namespaceMap);
Iterator entries = nsMap.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry me = (Map.Entry) entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
nsMap = Collections.unmodifiableMap(nsMap);
}
/** {@collect.stats}
* Returns the XPath expression to be evaluated.
*
* @return the XPath expression to be evaluated
*/
public String getXPath() {
return xPath;
}
/** {@collect.stats}
* Returns a map of namespace prefixes. Each key is a namespace prefix
* <code>String</code> that maps to a corresponding namespace URI
* <code>String</code>.
* <p>
* This implementation returns an {@link Collections#unmodifiableMap
* unmodifiable map}.
*
* @return a <code>Map</code> of namespace prefixes to namespace URIs (may
* be empty, but never <code>null</code>)
*/
public Map getNamespaceMap() {
return nsMap;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XPathType.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import java.util.Collections;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
/** {@collect.stats}
* The XML Schema Definition of the <code>XPath</code> element as defined in the
* <a href="http://www.w3.org/TR/xmldsig-filter2">
* W3C Recommendation for XML-Signature XPath Filter 2.0</a>:
* <pre><code>
* <schema xmlns="http://www.w3.org/2001/XMLSchema"
* xmlns:xf="http://www.w3.org/2002/06/xmldsig-filter2"
* targetNamespace="http://www.w3.org/2002/06/xmldsig-filter2"
* version="0.1" elementFormDefault="qualified">
*
* <element name="XPath"
* type="xf:XPathType"/>
*
* <complexType name="XPathType">
* <simpleContent>
* <extension base="string">
* <attribute name="Filter">
* <simpleType>
* <restriction base="string">
* <enumeration value="intersect"/>
* <enumeration value="subtract"/>
* <enumeration value="union"/>
* </restriction>
* </simpleType>
* </attribute>
* </extension>
* </simpleContent>
* </complexType>
* </code></pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XPathFilter2ParameterSpec
*/
public class XPathType {
/** {@collect.stats}
* Represents the filter set operation.
*/
public static class Filter {
private final String operation;
private Filter(String operation) {
this.operation = operation;
}
/** {@collect.stats}
* Returns the string form of the operation.
*
* @return the string form of the operation
*/
public String toString() {
return operation;
}
/** {@collect.stats}
* The intersect filter operation.
*/
public static final Filter INTERSECT = new Filter("intersect");
/** {@collect.stats}
* The subtract filter operation.
*/
public static final Filter SUBTRACT = new Filter("subtract");
/** {@collect.stats}
* The union filter operation.
*/
public static final Filter UNION = new Filter("union");
}
private final String expression;
private final Filter filter;
private Map nsMap;
/** {@collect.stats}
* Creates an <code>XPathType</code> instance with the specified XPath
* expression and filter.
*
* @param expression the XPath expression to be evaluated
* @param filter the filter operation ({@link Filter#INTERSECT},
* {@link Filter#SUBTRACT}, or {@link Filter#UNION})
* @throws NullPointerException if <code>expression</code> or
* <code>filter</code> is <code>null</code>
*/
public XPathType(String expression, Filter filter) {
if (expression == null) {
throw new NullPointerException("expression cannot be null");
}
if (filter == null) {
throw new NullPointerException("filter cannot be null");
}
this.expression = expression;
this.filter = filter;
this.nsMap = Collections.EMPTY_MAP;
}
/** {@collect.stats}
* Creates an <code>XPathType</code> instance with the specified XPath
* expression, filter, and namespace map. The map is copied to protect
* against subsequent modification.
*
* @param expression the XPath expression to be evaluated
* @param filter the filter operation ({@link Filter#INTERSECT},
* {@link Filter#SUBTRACT}, or {@link Filter#UNION})
* @param namespaceMap the map of namespace prefixes. Each key is a
* namespace prefix <code>String</code> that maps to a corresponding
* namespace URI <code>String</code>.
* @throws NullPointerException if <code>expression</code>,
* <code>filter</code> or <code>namespaceMap</code> are
* <code>null</code>
* @throws ClassCastException if any of the map's keys or entries are
* not of type <code>String</code>
*/
public XPathType(String expression, Filter filter, Map namespaceMap) {
this(expression, filter);
if (namespaceMap == null) {
throw new NullPointerException("namespaceMap cannot be null");
}
nsMap = new HashMap(namespaceMap);
Iterator entries = nsMap.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry me = (Map.Entry) entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
nsMap = Collections.unmodifiableMap(nsMap);
}
/** {@collect.stats}
* Returns the XPath expression to be evaluated.
*
* @return the XPath expression to be evaluated
*/
public String getExpression() {
return expression;
}
/** {@collect.stats}
* Returns the filter operation.
*
* @return the filter operation
*/
public Filter getFilter() {
return filter;
}
/** {@collect.stats}
* Returns a map of namespace prefixes. Each key is a namespace prefix
* <code>String</code> that maps to a corresponding namespace URI
* <code>String</code>.
* <p>
* This implementation returns an {@link Collections#unmodifiableMap
* unmodifiable map}.
*
* @return a <code>Map</code> of namespace prefixes to namespace URIs
* (may be empty, but never <code>null</code>)
*/
public Map getNamespaceMap() {
return nsMap;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: C14NMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.CanonicalizationMethod;
/** {@collect.stats}
* A specification of algorithm parameters for a {@link CanonicalizationMethod}
* Algorithm. The purpose of this interface is to group (and provide type
* safety for) all canonicalization (C14N) parameter specifications. All
* canonicalization parameter specifications must implement this interface.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see CanonicalizationMethod
*/
public interface C14NMethodParameterSpec extends TransformParameterSpec {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XPathFilter2ParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.crypto.dsig.Transform;
/** {@collect.stats}
* Parameters for the W3C Recommendation
* <a href="http://www.w3.org/TR/xmldsig-filter2/">
* XPath Filter 2.0 Transform Algorithm</a>.
* The parameters include a list of one or more {@link XPathType} objects.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see Transform
* @see XPathFilterParameterSpec
*/
public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
private final List xPathList;
/** {@collect.stats}
* Creates an <code>XPathFilter2ParameterSpec</code>.
*
* @param xPathList a list of one or more {@link XPathType} objects. The
* list is defensively copied to protect against subsequent modification.
* @throws ClassCastException if <code>xPathList</code> contains any
* entries that are not of type {@link XPathType}
* @throws IllegalArgumentException if <code>xPathList</code> is empty
* @throws NullPointerException if <code>xPathList</code> is
* <code>null</code>
*/
public XPathFilter2ParameterSpec(List xPathList) {
if (xPathList == null) {
throw new NullPointerException("xPathList cannot be null");
}
List xPathListCopy = new ArrayList(xPathList);
if (xPathListCopy.isEmpty()) {
throw new IllegalArgumentException("xPathList cannot be empty");
}
int size = xPathListCopy.size();
for (int i = 0; i < size; i++) {
if (!(xPathListCopy.get(i) instanceof XPathType)) {
throw new ClassCastException
("xPathList["+i+"] is not a valid type");
}
}
this.xPathList = Collections.unmodifiableList(xPathListCopy);
}
/** {@collect.stats}
* Returns a list of one or more {@link XPathType} objects.
* <p>
* This implementation returns an {@link Collections#unmodifiableList
* unmodifiable list}.
*
* @return a <code>List</code> of <code>XPathType</code> objects
* (never <code>null</code> or empty)
*/
public List getXPathList() {
return xPathList;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: TransformParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.Transform;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* A specification of algorithm parameters for a {@link Transform}
* algorithm. The purpose of this interface is to group (and provide type
* safety for) all transform parameter specifications. All transform parameter
* specifications must implement this interface.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see Transform
*/
public interface TransformParameterSpec extends AlgorithmParameterSpec {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: ExcC14NParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.CanonicalizationMethod;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** {@collect.stats}
* Parameters for the W3C Recommendation:
* <a href="http://www.w3.org/TR/xml-exc-c14n/">
* Exclusive XML Canonicalization (C14N) algorithm</a>. The
* parameters include an optional inclusive namespace prefix list. The XML
* Schema Definition of the Exclusive XML Canonicalization parameters is
* defined as:
* <pre><code>
* <schema xmlns="http://www.w3.org/2001/XMLSchema"
* xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"
* targetNamespace="http://www.w3.org/2001/10/xml-exc-c14n#"
* version="0.1" elementFormDefault="qualified">
*
* <element name="InclusiveNamespaces" type="ec:InclusiveNamespaces"/>
* <complexType name="InclusiveNamespaces">
* <attribute name="PrefixList" type="xsd:string"/>
* </complexType>
* </schema>
* </code></pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see CanonicalizationMethod
*/
public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
private List preList;
/** {@collect.stats}
* Indicates the default namespace ("#default").
*/
public static final String DEFAULT = "#default";
/** {@collect.stats}
* Creates a <code>ExcC14NParameterSpec</code> with an empty prefix
* list.
*/
public ExcC14NParameterSpec() {
preList = Collections.EMPTY_LIST;
}
/** {@collect.stats}
* Creates a <code>ExcC14NParameterSpec</code> with the specified list
* of prefixes. The list is copied to protect against subsequent
* modification.
*
* @param prefixList the inclusive namespace prefix list. Each entry in
* the list is a <code>String</code> that represents a namespace prefix.
* @throws NullPointerException if <code>prefixList</code> is
* <code>null</code>
* @throws ClassCastException if any of the entries in the list are not
* of type <code>String</code>
*/
public ExcC14NParameterSpec(List prefixList) {
if (prefixList == null) {
throw new NullPointerException("prefixList cannot be null");
}
this.preList = new ArrayList(prefixList);
for (int i = 0, size = preList.size(); i < size; i++) {
if (!(preList.get(i) instanceof String)) {
throw new ClassCastException("not a String");
}
}
preList = Collections.unmodifiableList(preList);
}
/** {@collect.stats}
* Returns the inclusive namespace prefix list. Each entry in the list
* is a <code>String</code> that represents a namespace prefix.
*
* <p>This implementation returns an {@link
* java.util.Collections#unmodifiableList unmodifiable list}.
*
* @return the inclusive namespace prefix list (may be empty but never
* <code>null</code>)
*/
public List getPrefixList() {
return preList;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XSLTTransformParameterSpec.java,v 1.4 2005/05/10 16:40:18 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* Parameters for the <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">
* XSLT Transform Algorithm</a>.
* The parameters include a namespace-qualified stylesheet element.
*
* <p>An <code>XSLTTransformParameterSpec</code> is instantiated with a
* mechanism-dependent (ex: DOM) stylesheet element. For example:
* <pre>
* DOMStructure stylesheet = new DOMStructure(element)
* XSLTTransformParameterSpec spec = new XSLTransformParameterSpec(stylesheet);
* </pre>
* where <code>element</code> is an {@link org.w3c.dom.Element} containing
* the namespace-qualified stylesheet element.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see Transform
*/
public final class XSLTTransformParameterSpec implements TransformParameterSpec{
private XMLStructure stylesheet;
/** {@collect.stats}
* Creates an <code>XSLTTransformParameterSpec</code> with the specified
* stylesheet.
*
* @param stylesheet the XSLT stylesheet to be used
* @throws NullPointerException if <code>stylesheet</code> is
* <code>null</code>
*/
public XSLTTransformParameterSpec(XMLStructure stylesheet) {
if (stylesheet == null) {
throw new NullPointerException();
}
this.stylesheet = stylesheet;
}
/** {@collect.stats}
* Returns the stylesheet.
*
* @return the stylesheet
*/
public XMLStructure getStylesheet() {
return stylesheet;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignatureMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.SignatureMethod;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* A specification of algorithm parameters for an XML {@link SignatureMethod}
* algorithm. The purpose of this interface is to group (and provide type
* safety for) all signature method parameter specifications. All signature
* method parameter specifications must implement this interface.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see SignatureMethod
*/
public interface SignatureMethodParameterSpec extends AlgorithmParameterSpec {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: HMACParameterSpec.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
*/
package javax.xml.crypto.dsig.spec;
import javax.xml.crypto.dsig.SignatureMethod;
/** {@collect.stats}
* Parameters for the <a href="http://www.w3.org/TR/xmldsig-core/#sec-MACs">
* XML Signature HMAC Algorithm</a>. The parameters include an optional output
* length which specifies the MAC truncation length in bits. The resulting
* HMAC will be truncated to the specified number of bits. If the parameter is
* not specified, then this implies that all the bits of the hash are to be
* output. The XML Schema Definition of the <code>HMACOutputLength</code>
* element is defined as:
* <pre><code>
* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
* <simpleType name="HMACOutputLengthType">
* <restriction base="integer"/>
* </simpleType>
* </code></pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see SignatureMethod
* @see <a href="http://www.ietf.org/rfc/rfc2104.txt">RFC 2104</a>
*/
public final class HMACParameterSpec implements SignatureMethodParameterSpec {
private int outputLength;
/** {@collect.stats}
* Creates an <code>HMACParameterSpec</code> with the specified truncation
* length.
*
* @param outputLength the truncation length in number of bits
*/
public HMACParameterSpec(int outputLength) {
this.outputLength = outputLength;
}
/** {@collect.stats}
* Returns the truncation length.
*
* @return the truncation length in number of bits
*/
public int getOutputLength() {
return outputLength;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeyInfo.java,v 1.7 2005/05/10 16:35:34 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import java.util.List;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>KeyInfo</code> element as defined in
* the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* A <code>KeyInfo</code> contains a list of {@link XMLStructure}s, each of
* which contain information that enables the recipient(s) to obtain the key
* needed to validate an XML signature. The XML Schema Definition is defined as:
*
* <pre>
* <element name="KeyInfo" type="ds:KeyInfoType"/>
* <complexType name="KeyInfoType" mixed="true">
* <choice maxOccurs="unbounded">
* <element ref="ds:KeyName"/>
* <element ref="ds:KeyValue"/>
* <element ref="ds:RetrievalMethod"/>
* <element ref="ds:X509Data"/>
* <element ref="ds:PGPData"/>
* <element ref="ds:SPKIData"/>
* <element ref="ds:MgmtData"/>
* <any processContents="lax" namespace="##other"/>
* <!-- (1,1) elements from (0,unbounded) namespaces -->
* </choice>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </pre>
*
* A <code>KeyInfo</code> instance may be created by invoking one of the
* {@link KeyInfoFactory#newKeyInfo newKeyInfo} methods of the
* {@link KeyInfoFactory} class, and passing it a list of one or more
* <code>XMLStructure</code>s and an optional id parameter;
* for example:
* <pre>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* KeyInfo keyInfo = factory.newKeyInfo
* (Collections.singletonList(factory.newKeyName("Alice"), "keyinfo-1"));
* </pre>
*
* <p><code>KeyInfo</code> objects can also be marshalled to XML by invoking
* the {@link #marshal marshal} method.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newKeyInfo(List)
* @see KeyInfoFactory#newKeyInfo(List, String)
*/
public interface KeyInfo extends XMLStructure {
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} containing the key information. Each entry of the list is
* an {@link XMLStructure}.
*
* <p>If there is a public subclass representing the type of
* <code>XMLStructure</code>, it is returned as an instance of that
* class (ex: an <code>X509Data</code> element would be returned as an
* instance of {@link javax.xml.crypto.dsig.keyinfo.X509Data}).
*
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
* in this <code>KeyInfo</code>. Never returns <code>null</code> or an
* empty list.
*/
List getContent();
/** {@collect.stats}
* Return the optional Id attribute of this <code>KeyInfo</code>, which
* may be useful for referencing this <code>KeyInfo</code> from other
* XML structures.
*
* @return the Id attribute of this <code>KeyInfo</code> (may be
* <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Marshals the key info to XML.
*
* @param parent a mechanism-specific structure containing the parent node
* that the marshalled key info will be appended to
* @param context the <code>XMLCryptoContext</code> containing additional
* context (may be null if not applicable)
* @throws ClassCastException if the type of <code>parent</code> or
* <code>context</code> is not compatible with this key info
* @throws MarshalException if the key info cannot be marshalled
* @throws NullPointerException if <code>parent</code> is <code>null</code>
*/
void marshal(XMLStructure parent, XMLCryptoContext context)
throws MarshalException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: PGPData.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import java.util.Collections;
import java.util.List;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>PGPData</code> element as defined in
* the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>. A
* <code>PGPData</code> object is used to convey information related to
* PGP public key pairs and signatures on such keys. The XML Schema Definition
* is defined as:
*
* <pre>
* <element name="PGPData" type="ds:PGPDataType"/>
* <complexType name="PGPDataType">
* <choice>
* <sequence>
* <element name="PGPKeyID" type="base64Binary"/>
* <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
* <any namespace="##other" processContents="lax" minOccurs="0"
* maxOccurs="unbounded"/>
* </sequence>
* <sequence>
* <element name="PGPKeyPacket" type="base64Binary"/>
* <any namespace="##other" processContents="lax" minOccurs="0"
* maxOccurs="unbounded"/>
* </sequence>
* </choice>
* </complexType>
* </pre>
*
* A <code>PGPData</code> instance may be created by invoking one of the
* {@link KeyInfoFactory#newPGPData newPGPData} methods of the {@link
* KeyInfoFactory} class, and passing it
* <code>byte</code> arrays representing the contents of the PGP public key
* identifier and/or PGP key material packet, and an optional list of
* elements from an external namespace.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newPGPData(byte[])
* @see KeyInfoFactory#newPGPData(byte[], byte[], List)
* @see KeyInfoFactory#newPGPData(byte[], List)
*/
public interface PGPData extends XMLStructure {
/** {@collect.stats}
* URI identifying the PGPData KeyInfo type:
* http://www.w3.org/2000/09/xmldsig#PGPData. This can be specified as the
* value of the <code>type</code> parameter of the {@link RetrievalMethod}
* class to describe a remote <code>PGPData</code> structure.
*/
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#PGPData";
/** {@collect.stats}
* Returns the PGP public key identifier of this <code>PGPData</code> as
* defined in <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>,
* section 11.2.
*
* @return the PGP public key identifier (may be <code>null</code> if
* not specified). Each invocation of this method returns a new clone
* to protect against subsequent modification.
*/
byte[] getKeyId();
/** {@collect.stats}
* Returns the PGP key material packet of this <code>PGPData</code> as
* defined in <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>,
* section 5.5.
*
* @return the PGP key material packet (may be <code>null</code> if not
* specified). Each invocation of this method returns a new clone to
* protect against subsequent modification.
*/
byte[] getKeyPacket();
/** {@collect.stats}
* Returns an {@link Collections#unmodifiableList unmodifiable list}
* of {@link XMLStructure}s representing elements from an external
* namespace.
*
* @return an unmodifiable list of <code>XMLStructure</code>s (may be
* empty, but never <code>null</code>)
*/
List getExternalElements();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeyName.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>KeyName</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* A <code>KeyName</code> object contains a string value which may be used
* by the signer to communicate a key identifier to the recipient. The
* XML Schema Definition is defined as:
*
* <pre>
* <element name="KeyName" type="string"/>
* </pre>
*
* A <code>KeyName</code> instance may be created by invoking the
* {@link KeyInfoFactory#newKeyName newKeyName} method of the
* {@link KeyInfoFactory} class, and passing it a <code>String</code>
* representing the name of the key; for example:
* <pre>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* KeyName keyName = factory.newKeyName("Alice");
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newKeyName(String)
*/
public interface KeyName extends XMLStructure {
/** {@collect.stats}
* Returns the name of this <code>KeyName</code>.
*
* @return the name of this <code>KeyName</code> (never
* <code>null</code>)
*/
String getName();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeyValue.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import java.security.KeyException;
import java.security.KeyStore;
import java.security.PublicKey;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.RSAPublicKey;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>KeyValue</code> element as defined
* in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>. A
* <code>KeyValue</code> object contains a single public key that may be
* useful in validating the signature. The XML schema definition is defined as:
*
* <pre>
* <element name="KeyValue" type="ds:KeyValueType"/>
* <complexType name="KeyValueType" mixed="true">
* <choice>
* <element ref="ds:DSAKeyValue"/>
* <element ref="ds:RSAKeyValue"/>
* <any namespace="##other" processContents="lax"/>
* </choice>
* </complexType>
*
* <element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
* <complexType name="DSAKeyValueType">
* <sequence>
* <sequence minOccurs="0">
* <element name="P" type="ds:CryptoBinary"/>
* <element name="Q" type="ds:CryptoBinary"/>
* </sequence>
* <element name="G" type="ds:CryptoBinary" minOccurs="0"/>
* <element name="Y" type="ds:CryptoBinary"/>
* <element name="J" type="ds:CryptoBinary" minOccurs="0"/>
* <sequence minOccurs="0">
* <element name="Seed" type="ds:CryptoBinary"/>
* <element name="PgenCounter" type="ds:CryptoBinary"/>
* </sequence>
* </sequence>
* </complexType>
*
* <element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
* <complexType name="RSAKeyValueType">
* <sequence>
* <element name="Modulus" type="ds:CryptoBinary"/>
* <element name="Exponent" type="ds:CryptoBinary"/>
* </sequence>
* </complexType>
* </pre>
* A <code>KeyValue</code> instance may be created by invoking the
* {@link KeyInfoFactory#newKeyValue newKeyValue} method of the
* {@link KeyInfoFactory} class, and passing it a {@link
* java.security.PublicKey} representing the value of the public key. Here is
* an example of creating a <code>KeyValue</code> from a {@link DSAPublicKey}
* of a {@link java.security.cert.Certificate} stored in a
* {@link java.security.KeyStore}:
* <pre>
* KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
* PublicKey dsaPublicKey = keyStore.getCertificate("myDSASigningCert").getPublicKey();
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* KeyValue keyValue = factory.newKeyValue(dsaPublicKey);
* </pre>
*
* This class returns the <code>DSAKeyValue</code> and
* <code>RSAKeyValue</code> elements as objects of type
* {@link DSAPublicKey} and {@link RSAPublicKey}, respectively. Note that not
* all of the fields in the schema are accessible as parameters of these
* types.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newKeyValue(PublicKey)
*/
public interface KeyValue extends XMLStructure {
/** {@collect.stats}
* URI identifying the DSA KeyValue KeyInfo type:
* http://www.w3.org/2000/09/xmldsig#DSAKeyValue. This can be specified as
* the value of the <code>type</code> parameter of the
* {@link RetrievalMethod} class to describe a remote
* <code>DSAKeyValue</code> structure.
*/
final static String DSA_TYPE =
"http://www.w3.org/2000/09/xmldsig#DSAKeyValue";
/** {@collect.stats}
* URI identifying the RSA KeyValue KeyInfo type:
* http://www.w3.org/2000/09/xmldsig#RSAKeyValue. This can be specified as
* the value of the <code>type</code> parameter of the
* {@link RetrievalMethod} class to describe a remote
* <code>RSAKeyValue</code> structure.
*/
final static String RSA_TYPE =
"http://www.w3.org/2000/09/xmldsig#RSAKeyValue";
/** {@collect.stats}
* Returns the public key of this <code>KeyValue</code>.
*
* @return the public key of this <code>KeyValue</code>
* @throws KeyException if this <code>KeyValue</code> cannot be converted
* to a <code>PublicKey</code>
*/
PublicKey getPublicKey() throws KeyException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: X509Data.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import javax.xml.crypto.XMLStructure;
import java.security.cert.X509CRL;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>X509Data</code> element as defined in
* the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>. An
* <code>X509Data</code> object contains one or more identifers of keys
* or X.509 certificates (or certificates' identifiers or a revocation list).
* The XML Schema Definition is defined as:
*
* <pre>
* <element name="X509Data" type="ds:X509DataType"/>
* <complexType name="X509DataType">
* <sequence maxOccurs="unbounded">
* <choice>
* <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
* <element name="X509SKI" type="base64Binary"/>
* <element name="X509SubjectName" type="string"/>
* <element name="X509Certificate" type="base64Binary"/>
* <element name="X509CRL" type="base64Binary"/>
* <any namespace="##other" processContents="lax"/>
* </choice>
* </sequence>
* </complexType>
*
* <complexType name="X509IssuerSerialType">
* <sequence>
* <element name="X509IssuerName" type="string"/>
* <element name="X509SerialNumber" type="integer"/>
* </sequence>
* </complexType>
* </pre>
*
* An <code>X509Data</code> instance may be created by invoking the
* {@link KeyInfoFactory#newX509Data newX509Data} methods of the
* {@link KeyInfoFactory} class and passing it a list of one or more
* {@link XMLStructure}s representing X.509 content; for example:
* <pre>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* X509Data x509Data = factory.newX509Data
* (Collections.singletonList("cn=Alice"));
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newX509Data(List)
*/
//@@@ check for illegal combinations of data violating MUSTs in W3c spec
public interface X509Data extends XMLStructure {
/** {@collect.stats}
* URI identifying the X509Data KeyInfo type:
* http://www.w3.org/2000/09/xmldsig#X509Data. This can be specified as
* the value of the <code>type</code> parameter of the
* {@link RetrievalMethod} class to describe a remote
* <code>X509Data</code> structure.
*/
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#X509Data";
/** {@collect.stats}
* URI identifying the binary (ASN.1 DER) X.509 Certificate KeyInfo type:
* http://www.w3.org/2000/09/xmldsig#rawX509Certificate. This can be
* specified as the value of the <code>type</code> parameter of the
* {@link RetrievalMethod} class to describe a remote X509 Certificate.
*/
final static String RAW_X509_CERTIFICATE_TYPE =
"http://www.w3.org/2000/09/xmldsig#rawX509Certificate";
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of the content in this <code>X509Data</code>. Valid types are
* {@link String} (subject names), <code>byte[]</code> (subject key ids),
* {@link java.security.cert.X509Certificate}, {@link X509CRL},
* or {@link XMLStructure} ({@link X509IssuerSerial}
* objects or elements from an external namespace).
*
* @return an unmodifiable list of the content in this <code>X509Data</code>
* (never <code>null</code> or empty)
*/
List getContent();
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeyInfoFactory.java,v 1.12 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import java.math.BigInteger;
import java.security.KeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.cert.X509CRL;
import java.util.List;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.NoSuchMechanismException;
import javax.xml.crypto.URIDereferencer;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMStructure;
import javax.xml.crypto.dsig.*;
import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance;
/** {@collect.stats}
* A factory for creating {@link KeyInfo} objects from scratch or for
* unmarshalling a <code>KeyInfo</code> object from a corresponding XML
* representation.
*
* <p>Each instance of <code>KeyInfoFactory</code> supports a specific
* XML mechanism type. To create a <code>KeyInfoFactory</code>, call one of the
* static {@link #getInstance getInstance} methods, passing in the XML
* mechanism type desired, for example:
*
* <blockquote><code>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* </code></blockquote>
*
* <p>The objects that this factory produces will be based
* on DOM and abide by the DOM interoperability requirements as defined in the
* <a href="../../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
* DOM Mechanism Requirements</a> section of the API overview. See the
* <a href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of standard
* mechanism types.
*
* <p><code>KeyInfoFactory</code> implementations are registered and loaded
* using the {@link java.security.Provider} mechanism.
* For example, a service provider that supports the
* DOM mechanism would be specified in the <code>Provider</code> subclass as:
* <pre>
* put("KeyInfoFactory.DOM", "org.example.DOMKeyInfoFactory");
* </pre>
*
* <p>Also, the <code>XMLStructure</code>s that are created by this factory
* may contain state specific to the <code>KeyInfo</code> and are not
* intended to be reusable.
*
* <p>An implementation MUST minimally support the default mechanism type: DOM.
*
* <p>Note that a caller must use the same <code>KeyInfoFactory</code>
* instance to create the <code>XMLStructure</code>s of a particular
* <code>KeyInfo</code> object. The behavior is undefined if
* <code>XMLStructure</code>s from different providers or different mechanism
* types are used together.
*
* <p><b>Concurrent Access</b>
* <p>The static methods of this class are guaranteed to be thread-safe.
* Multiple threads may concurrently invoke the static methods defined in this
* class with no ill effects.
*
* <p>However, this is not true for the non-static methods defined by this
* class. Unless otherwise documented by a specific provider, threads that
* need to access a single <code>KeyInfoFactory</code> instance concurrently
* should synchronize amongst themselves and provide the necessary locking.
* Multiple threads each manipulating a different <code>KeyInfoFactory</code>
* instance need not synchronize.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public abstract class KeyInfoFactory {
private String mechanismType;
private Provider provider;
/** {@collect.stats}
* Default constructor, for invocation by subclasses.
*/
protected KeyInfoFactory() {}
/** {@collect.stats}
* Returns a <code>KeyInfoFactory</code> that supports the
* specified XML processing mechanism and representation type (ex: "DOM").
*
* <p>This method uses the standard JCA provider lookup mechanism to
* locate and instantiate a <code>KeyInfoFactory</code> implementation of
* the desired mechanism type. It traverses the list of registered security
* <code>Provider</code>s, starting with the most preferred
* <code>Provider</code>. A new <code>KeyInfoFactory</code> object
* from the first <code>Provider</code> that supports the specified
* mechanism is returned.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @return a new <code>KeyInfoFactory</code>
* @throws NullPointerException if <code>mechanismType</code> is
* <code>null</code>
* @throws NoSuchMechanismException if no <code>Provider</code> supports a
* <code>KeyInfoFactory</code> implementation for the specified mechanism
* @see Provider
*/
public static KeyInfoFactory getInstance(String mechanismType) {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
}
Instance instance;
try {
instance = GetInstance.getInstance
("KeyInfoFactory", null, mechanismType);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns a <code>KeyInfoFactory</code> that supports the
* requested XML processing mechanism and representation type (ex: "DOM"),
* as supplied by the specified provider. Note that the specified
* <code>Provider</code> object does not have to be registered in the
* provider list.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @param provider the <code>Provider</code> object
* @return a new <code>KeyInfoFactory</code>
* @throws NullPointerException if <code>mechanismType</code> or
* <code>provider</code> are <code>null</code>
* @throws NoSuchMechanismException if a <code>KeyInfoFactory</code>
* implementation for the specified mechanism is not available from the
* specified <code>Provider</code> object
* @see Provider
*/
public static KeyInfoFactory getInstance(String mechanismType,
Provider provider) {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
} else if (provider == null) {
throw new NullPointerException("provider cannot be null");
}
Instance instance;
try {
instance = GetInstance.getInstance
("KeyInfoFactory", null, mechanismType, provider);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns a <code>KeyInfoFactory</code> that supports the
* requested XML processing mechanism and representation type (ex: "DOM"),
* as supplied by the specified provider. The specified provider must be
* registered in the security provider list.
*
* <p>Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param mechanismType the type of the XML processing mechanism and
* representation. See the <a
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
* Service Providers</a> section of the API overview for a list of
* standard mechanism types.
* @param provider the string name of the provider
* @return a new <code>KeyInfoFactory</code>
* @throws NoSuchProviderException if the specified provider is not
* registered in the security provider list
* @throws NullPointerException if <code>mechanismType</code> or
* <code>provider</code> are <code>null</code>
* @throws NoSuchMechanismException if a <code>KeyInfoFactory</code>
* implementation for the specified mechanism is not available from the
* specified provider
* @see Provider
*/
public static KeyInfoFactory getInstance(String mechanismType,
String provider) throws NoSuchProviderException {
if (mechanismType == null) {
throw new NullPointerException("mechanismType cannot be null");
} else if (provider == null) {
throw new NullPointerException("provider cannot be null");
} else if (provider.length() == 0) {
throw new NoSuchProviderException();
}
Instance instance;
try {
instance = GetInstance.getInstance
("KeyInfoFactory", null, mechanismType, provider);
} catch (NoSuchAlgorithmException nsae) {
throw new NoSuchMechanismException(nsae);
}
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
factory.mechanismType = mechanismType;
factory.provider = instance.provider;
return factory;
}
/** {@collect.stats}
* Returns a <code>KeyInfoFactory</code> that supports the
* default XML processing mechanism and representation type ("DOM").
*
* <p>This method uses the standard JCA provider lookup mechanism to
* locate and instantiate a <code>KeyInfoFactory</code> implementation of
* the default mechanism type. It traverses the list of registered security
* <code>Provider</code>s, starting with the most preferred
* <code>Provider</code>. A new <code>KeyInfoFactory</code> object
* from the first <code>Provider</code> that supports the DOM mechanism is
* returned.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @return a new <code>KeyInfoFactory</code>
* @throws NoSuchMechanismException if no <code>Provider</code> supports a
* <code>KeyInfoFactory</code> implementation for the DOM mechanism
* @see Provider
*/
public static KeyInfoFactory getInstance() {
return getInstance("DOM");
}
/** {@collect.stats}
* Returns the type of the XML processing mechanism and representation
* supported by this <code>KeyInfoFactory</code> (ex: "DOM")
*
* @return the XML processing mechanism type supported by this
* <code>KeyInfoFactory</code>
*/
public final String getMechanismType() {
return mechanismType;
}
/** {@collect.stats}
* Returns the provider of this <code>KeyInfoFactory</code>.
*
* @return the provider of this <code>KeyInfoFactory</code>
*/
public final Provider getProvider() {
return provider;
}
/** {@collect.stats}
* Creates a <code>KeyInfo</code> containing the specified list of
* key information types.
*
* @param content a list of one or more {@link XMLStructure}s representing
* key information types. The list is defensively copied to protect
* against subsequent modification.
* @return a <code>KeyInfo</code>
* @throws NullPointerException if <code>content</code> is <code>null</code>
* @throws IllegalArgumentException if <code>content</code> is empty
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
public abstract KeyInfo newKeyInfo(List content);
/** {@collect.stats}
* Creates a <code>KeyInfo</code> containing the specified list of key
* information types and optional id. The
* <code>id</code> parameter represents the value of an XML
* <code>ID</code> attribute and is useful for referencing
* the <code>KeyInfo</code> from other XML structures.
*
* @param content a list of one or more {@link XMLStructure}s representing
* key information types. The list is defensively copied to protect
* against subsequent modification.
* @param id the value of an XML <code>ID</code> (may be <code>null</code>)
* @return a <code>KeyInfo</code>
* @throws NullPointerException if <code>content</code> is <code>null</code>
* @throws IllegalArgumentException if <code>content</code> is empty
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
public abstract KeyInfo newKeyInfo(List content, String id);
/** {@collect.stats}
* Creates a <code>KeyName</code> from the specified name.
*
* @param name the name that identifies the key
* @return a <code>KeyName</code>
* @throws NullPointerException if <code>name</code> is <code>null</code>
*/
public abstract KeyName newKeyName(String name);
/** {@collect.stats}
* Creates a <code>KeyValue</code> from the specified public key.
*
* @param key the public key
* @return a <code>KeyValue</code>
* @throws KeyException if the <code>key</code>'s algorithm is not
* recognized or supported by this <code>KeyInfoFactory</code>
* @throws NullPointerException if <code>key</code> is <code>null</code>
*/
public abstract KeyValue newKeyValue(PublicKey key) throws KeyException;
/** {@collect.stats}
* Creates a <code>PGPData</code> from the specified PGP public key
* identifier.
*
* @param keyId a PGP public key identifier as defined in <a href=
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 11.2.
* The array is cloned to protect against subsequent modification.
* @return a <code>PGPData</code>
* @throws NullPointerException if <code>keyId</code> is <code>null</code>
* @throws IllegalArgumentException if the key id is not in the correct
* format
*/
public abstract PGPData newPGPData(byte[] keyId);
/** {@collect.stats}
* Creates a <code>PGPData</code> from the specified PGP public key
* identifier, and optional key material packet and list of external
* elements.
*
* @param keyId a PGP public key identifier as defined in <a href=
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 11.2.
* The array is cloned to protect against subsequent modification.
* @param keyPacket a PGP key material packet as defined in <a href=
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 5.5.
* The array is cloned to protect against subsequent modification. May
* be <code>null</code>.
* @param other a list of {@link XMLStructure}s representing elements from
* an external namespace. The list is defensively copied to protect
* against subsequent modification. May be <code>null</code> or empty.
* @return a <code>PGPData</code>
* @throws NullPointerException if <code>keyId</code> is <code>null</code>
* @throws IllegalArgumentException if the <code>keyId</code> or
* <code>keyPacket</code> is not in the correct format. For
* <code>keyPacket</code>, the format of the packet header is
* checked and the tag is verified that it is of type key material. The
* contents and format of the packet body are not checked.
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket,
List other);
/** {@collect.stats}
* Creates a <code>PGPData</code> from the specified PGP key material
* packet and optional list of external elements.
*
* @param keyPacket a PGP key material packet as defined in <a href=
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 5.5.
* The array is cloned to protect against subsequent modification.
* @param other a list of {@link XMLStructure}s representing elements from
* an external namespace. The list is defensively copied to protect
* against subsequent modification. May be <code>null</code> or empty.
* @return a <code>PGPData</code>
* @throws NullPointerException if <code>keyPacket</code> is
* <code>null</code>
* @throws IllegalArgumentException if <code>keyPacket</code> is not in the
* correct format. For <code>keyPacket</code>, the format of the packet
* header is checked and the tag is verified that it is of type key
* material. The contents and format of the packet body are not checked.
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
public abstract PGPData newPGPData(byte[] keyPacket, List other);
/** {@collect.stats}
* Creates a <code>RetrievalMethod</code> from the specified URI.
*
* @param uri the URI that identifies the <code>KeyInfo</code> information
* to be retrieved
* @return a <code>RetrievalMethod</code>
* @throws NullPointerException if <code>uri</code> is <code>null</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant
*/
public abstract RetrievalMethod newRetrievalMethod(String uri);
/** {@collect.stats}
* Creates a <code>RetrievalMethod</code> from the specified parameters.
*
* @param uri the URI that identifies the <code>KeyInfo</code> information
* to be retrieved
* @param type a URI that identifies the type of <code>KeyInfo</code>
* information to be retrieved (may be <code>null</code>)
* @param transforms a list of {@link Transform}s. The list is defensively
* copied to protect against subsequent modification. May be
* <code>null</code> or empty.
* @return a <code>RetrievalMethod</code>
* @throws NullPointerException if <code>uri</code> is <code>null</code>
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
* compliant
* @throws ClassCastException if <code>transforms</code> contains any
* entries that are not of type {@link Transform}
*/
public abstract RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms);
/** {@collect.stats}
* Creates a <code>X509Data</code> containing the specified list of
* X.509 content.
*
* @param content a list of one or more X.509 content types. Valid types are
* {@link String} (subject names), <code>byte[]</code> (subject key ids),
* {@link java.security.cert.X509Certificate}, {@link X509CRL},
* or {@link XMLStructure} ({@link X509IssuerSerial}
* objects or elements from an external namespace). Subject names are
* distinguished names in RFC 2253 String format. Implementations MUST
* support the attribute type keywords defined in RFC 2253 (CN, L, ST,
* O, OU, C, STREET, DC and UID). Implementations MAY support additional
* keywords. The list is defensively copied to protect against
* subsequent modification.
* @return a <code>X509Data</code>
* @throws NullPointerException if <code>content</code> is <code>null</code>
* @throws IllegalArgumentException if <code>content</code> is empty, or
* if a subject name is not RFC 2253 compliant or one of the attribute
* type keywords is not recognized.
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of one of the valid types mentioned above
*/
public abstract X509Data newX509Data(List content);
/** {@collect.stats}
* Creates an <code>X509IssuerSerial</code> from the specified X.500 issuer
* distinguished name and serial number.
*
* @param issuerName the issuer's distinguished name in RFC 2253 String
* format. Implementations MUST support the attribute type keywords
* defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC and UID).
* Implementations MAY support additional keywords.
* @param serialNumber the serial number
* @return an <code>X509IssuerSerial</code>
* @throws NullPointerException if <code>issuerName</code> or
* <code>serialNumber</code> are <code>null</code>
* @throws IllegalArgumentException if the issuer name is not RFC 2253
* compliant or one of the attribute type keywords is not recognized.
*/
public abstract X509IssuerSerial newX509IssuerSerial
(String issuerName, BigInteger serialNumber);
/** {@collect.stats}
* Indicates whether a specified feature is supported.
*
* @param feature the feature name (as an absolute URI)
* @return <code>true</code> if the specified feature is supported,
* <code>false</code> otherwise
* @throws NullPointerException if <code>feature</code> is <code>null</code>
*/
public abstract boolean isFeatureSupported(String feature);
/** {@collect.stats}
* Returns a reference to the <code>URIDereferencer</code> that is used by
* default to dereference URIs in {@link RetrievalMethod} objects.
*
* @return a reference to the default <code>URIDereferencer</code>
*/
public abstract URIDereferencer getURIDereferencer();
/** {@collect.stats}
* Unmarshals a new <code>KeyInfo</code> instance from a
* mechanism-specific <code>XMLStructure</code> (ex: {@link DOMStructure})
* instance.
*
* @param xmlStructure a mechanism-specific XML structure from which to
* unmarshal the keyinfo from
* @return the <code>KeyInfo</code>
* @throws NullPointerException if <code>xmlStructure</code> is
* <code>null</code>
* @throws ClassCastException if the type of <code>xmlStructure</code> is
* inappropriate for this factory
* @throws MarshalException if an unrecoverable exception occurs during
* unmarshalling
*/
public abstract KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure)
throws MarshalException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: X509IssuerSerial.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import java.math.BigInteger;
import java.security.cert.X509Certificate;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>X509IssuerSerial</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* An <code>X509IssuerSerial</code> object contains an X.509 issuer
* distinguished name (DN) and serial number pair. The XML schema definition is
* defined as:
*
* <pre>
* <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
* <complexType name="X509IssuerSerialType">
* <sequence>
* <element name="X509IssuerName" type="string"/>
* <element name="X509SerialNumber" type="integer"/>
* </sequence>
* </complexType>
* </pre>
*
* An <code>X509IssuerSerial</code> instance may be created by invoking the
* {@link KeyInfoFactory#newX509IssuerSerial newX509IssuerSerial} method
* of the {@link KeyInfoFactory} class, and passing it a
* <code>String</code> and <code>BigInteger</code> representing the X.500
* DN and serial number. Here is an example of creating an
* <code>X509IssuerSerial</code> from the issuer DN and serial number of an
* existing {@link X509Certificate}:
* <pre>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* X509IssuerSerial issuer = factory.newX509IssuerSerial
* (cert.getIssuerX500Principal().getName(), cert.getSerialNumber());
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see X509Data#getContent
* @see KeyInfoFactory#newX509IssuerSerial(String, BigInteger)
*/
public interface X509IssuerSerial extends XMLStructure {
/** {@collect.stats}
* Returns the X.500 distinguished name of this
* <code>X509IssuerSerial</code> in
* <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a> String format.
*
* @return the X.500 distinguished name in RFC 2253 String format (never
* <code>null</code>)
*/
String getIssuerName();
/** {@collect.stats}
* Returns the serial number of this <code>X509IssuerSerial</code>.
*
* @return the serial number (never <code>null</code>)
*/
BigInteger getSerialNumber();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: RetrievalMethod.java,v 1.8 2005/05/10 16:35:35 mullan Exp $
*/
package javax.xml.crypto.dsig.keyinfo;
import javax.xml.crypto.Data;
import javax.xml.crypto.URIReference;
import javax.xml.crypto.URIReferenceException;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.Transform;
import java.util.List;
/** {@collect.stats}
* A representation of the XML <code>RetrievalMethod</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* A <code>RetrievalMethod</code> object is used to convey a reference to
* <code>KeyInfo</code> information that is stored at another location.
* The XML schema definition is defined as:
*
* <pre>
* <element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
* <complexType name="RetrievalMethodType">
* <sequence>
* <element name="Transforms" type="ds:TransformsType" minOccurs="0"/>
* </sequence>
* <attribute name="URI" type="anyURI"/>
* <attribute name="Type" type="anyURI" use="optional"/>
* </complexType>
* </pre>
*
* A <code>RetrievalMethod</code> instance may be created by invoking one of the
* {@link KeyInfoFactory#newRetrievalMethod newRetrievalMethod} methods
* of the {@link KeyInfoFactory} class, and passing it the URI
* identifying the location of the KeyInfo, an optional type URI identifying
* the type of KeyInfo, and an optional list of {@link Transform}s; for example:
* <pre>
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
* RetrievalMethod rm = factory.newRetrievalMethod
* ("#KeyValue-1", KeyValue.DSA_TYPE, Collections.singletonList(Transform.BASE64));
* </pre>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see KeyInfoFactory#newRetrievalMethod(String)
* @see KeyInfoFactory#newRetrievalMethod(String, String, List)
*/
public interface RetrievalMethod extends URIReference, XMLStructure {
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of {@link Transform}s of this <code>RetrievalMethod</code>.
*
* @return an unmodifiable list of <code>Transform</code> objects (may be
* empty but never <code>null</code>).
*/
List getTransforms();
/** {@collect.stats}
* Returns the URI of the referenced <code>KeyInfo</code> information.
*
* @return the URI of the referenced <code>KeyInfo</code> information in
* RFC 2396 format (never <code>null</code>)
*/
String getURI();
/** {@collect.stats}
* Dereferences the <code>KeyInfo</code> information referenced by this
* <code>RetrievalMethod</code> and applies the specified
* <code>Transform</code>s.
*
* @param context an <code>XMLCryptoContext</code> that may contain
* additional useful information for dereferencing the URI. The
* context's <code>baseURI</code> and <code>dereferencer</code>
* parameters (if specified) are used to resolve and dereference this
* <code>RetrievalMethod</code>
* @return a <code>Data</code> object representing the raw contents of the
* <code>KeyInfo</code> information referenced by this
* <code>RetrievalMethod</code>. It is the caller's responsibility to
* convert the returned data to an appropriate
* <code>KeyInfo</code> object.
* @throws NullPointerException if <code>context</code> is <code>null</code>
* @throws URIReferenceException if there is an error while dereferencing
*/
Data dereference(XMLCryptoContext context) throws URIReferenceException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
*
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
*
* ===========================================================================
*/
/*
* $Id: XMLObject.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.util.List;
import javax.xml.crypto.XMLStructure;
/** {@collect.stats}
* A representation of the XML <code>Object</code> element as defined in
* the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* An <code>XMLObject</code> may contain any data and may include optional
* MIME type, ID, and encoding attributes. The XML Schema Definition is
* defined as:
*
* <pre><code>
* <element name="Object" type="ds:ObjectType"/>
* <complexType name="ObjectType" mixed="true">
* <sequence minOccurs="0" maxOccurs="unbounded">
* <any namespace="##any" processContents="lax"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* <attribute name="MimeType" type="string" use="optional"/>
* <attribute name="Encoding" type="anyURI" use="optional"/>
* </complexType>
* </code></pre>
*
* A <code>XMLObject</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newXMLObject newXMLObject} method of the
* {@link XMLSignatureFactory} class; for example:
*
* <pre>
* XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
* List content = Collections.singletonList(fac.newManifest(references)));
* XMLObject object = factory.newXMLObject(content, "object-1", null, null);
* </pre>
*
* <p>Note that this class is named <code>XMLObject</code> rather than
* <code>Object</code> to avoid naming clashes with the existing
* {@link java.lang.Object java.lang.Object} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @author Joyce L. Leung
* @since 1.6
* @see XMLSignatureFactory#newXMLObject(List, String, String, String)
*/
public interface XMLObject extends XMLStructure {
/** {@collect.stats}
* URI that identifies the <code>Object</code> element (this can be
* specified as the value of the <code>type</code> parameter of the
* {@link Reference} class to identify the referent's type).
*/
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#Object";
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of {@link XMLStructure}s contained in this <code>XMLObject</code>,
* which represent elements from any namespace.
*
*<p>If there is a public subclass representing the type of
* <code>XMLStructure</code>, it is returned as an instance of that class
* (ex: a <code>SignatureProperties</code> element would be returned
* as an instance of {@link javax.xml.crypto.dsig.SignatureProperties}).
*
* @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
* but never <code>null</code>)
*/
List getContent();
/** {@collect.stats}
* Returns the Id of this <code>XMLObject</code>.
*
* @return the Id (or <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Returns the mime type of this <code>XMLObject</code>. The
* mime type is an optional attribute which describes the data within this
* <code>XMLObject</code> (independent of its encoding).
*
* @return the mime type (or <code>null</code> if not specified)
*/
String getMimeType();
/** {@collect.stats}
* Returns the encoding URI of this <code>XMLObject</code>. The encoding
* URI identifies the method by which the object is encoded.
*
* @return the encoding URI (or <code>null</code> if not specified)
*/
String getEncoding();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: Transform.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import java.io.OutputStream;
import java.security.spec.AlgorithmParameterSpec;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.Data;
import javax.xml.crypto.OctetStreamData;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
/** {@collect.stats}
* A representation of the XML <code>Transform</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
*
* <pre>
* <element name="Transform" type="ds:TransformType"/>
* <complexType name="TransformType" mixed="true">
* <choice minOccurs="0" maxOccurs="unbounded">
* <any namespace="##other" processContents="lax"/>
* <!-- (1,1) elements from (0,unbounded) namespaces -->
* <element name="XPath" type="string"/>
* </choice>
* <attribute name="Algorithm" type="anyURI" use="required"/>
* </complexType>
* </pre>
*
* A <code>Transform</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newTransform newTransform} method
* of the {@link XMLSignatureFactory} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newTransform(String, TransformParameterSpec)
*/
public interface Transform extends XMLStructure, AlgorithmMethod {
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#base64">Base64</a>
* transform algorithm URI.
*/
final static String BASE64 = "http://www.w3.org/2000/09/xmldsig#base64";
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#enveloped-signature">
* Enveloped Signature</a> transform algorithm URI.
*/
final static String ENVELOPED =
"http://www.w3.org/2000/09/xmldsig#enveloped-signature";
/** {@collect.stats}
* The <a href="http://www.w3.org/TR/1999/REC-xpath-19991116">XPath</a>
* transform algorithm URI.
*/
final static String XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
/** {@collect.stats}
* The <a href="http://www.w3.org/2002/06/xmldsig-filter2">
* XPath Filter 2</a> transform algorithm URI.
*/
final static String XPATH2 = "http://www.w3.org/2002/06/xmldsig-filter2";
/** {@collect.stats}
* The <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT</a>
* transform algorithm URI.
*/
final static String XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116";
/** {@collect.stats}
* Returns the algorithm-specific input parameters associated with this
* <code>Transform</code>.
* <p>
* The returned parameters can be typecast to a
* {@link TransformParameterSpec} object.
*
* @return the algorithm-specific input parameters (may be <code>null</code>
* if not specified)
*/
AlgorithmParameterSpec getParameterSpec();
/** {@collect.stats}
* Transforms the specified data using the underlying transform algorithm.
*
* @param data the data to be transformed
* @param context the <code>XMLCryptoContext</code> containing
* additional context (may be <code>null</code> if not applicable)
* @return the transformed data
* @throws NullPointerException if <code>data</code> is <code>null</code>
* @throws TransformException if an error occurs while executing the
* transform
*/
public abstract Data transform(Data data, XMLCryptoContext context)
throws TransformException;
/** {@collect.stats}
* Transforms the specified data using the underlying transform algorithm.
* If the output of this transform is an <code>OctetStreamData</code>, then
* this method returns <code>null</code> and the bytes are written to the
* specified <code>OutputStream</code>. Otherwise, the
* <code>OutputStream</code> is ignored and the method behaves as if
* {@link #transform(Data, XMLCryptoContext)} were invoked.
*
* @param data the data to be transformed
* @param context the <code>XMLCryptoContext</code> containing
* additional context (may be <code>null</code> if not applicable)
* @param os the <code>OutputStream</code> that should be used to write
* the transformed data to
* @return the transformed data (or <code>null</code> if the data was
* written to the <code>OutputStream</code> parameter)
* @throws NullPointerException if <code>data</code> or <code>os</code>
* is <code>null</code>
* @throws TransformException if an error occurs while executing the
* transform
*/
public abstract Data transform
(Data data, XMLCryptoContext context, OutputStream os)
throws TransformException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DOMSignContext.java,v 1.9 2005/05/10 16:31:14 mullan Exp $
*/
package javax.xml.crypto.dsig.dom;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignContext;
import javax.xml.crypto.dsig.XMLSignature;
import java.security.Key;
import org.w3c.dom.Node;
/** {@collect.stats}
* A DOM-specific {@link XMLSignContext}. This class contains additional methods
* to specify the location in a DOM tree where an {@link XMLSignature}
* object is to be marshalled when generating the signature.
*
* <p>Note that <code>DOMSignContext</code> instances can contain
* information and state specific to the XML signature structure it is
* used with. The results are unpredictable if a
* <code>DOMSignContext</code> is used with different signature structures
* (for example, you should not use the same <code>DOMSignContext</code>
* instance to sign two different {@link XMLSignature} objects).
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public class DOMSignContext extends DOMCryptoContext implements XMLSignContext {
private Node parent;
private Node nextSibling;
/** {@collect.stats}
* Creates a <code>DOMSignContext</code> with the specified signing key
* and parent node. The signing key is stored in a
* {@link KeySelector#singletonKeySelector singleton KeySelector} that is
* returned by the {@link #getKeySelector getKeySelector} method.
* The marshalled <code>XMLSignature</code> will be added as the last
* child element of the specified parent node unless a next sibling node is
* specified by invoking the {@link #setNextSibling setNextSibling} method.
*
* @param signingKey the signing key
* @param parent the parent node
* @throws NullPointerException if <code>signingKey</code> or
* <code>parent</code> is <code>null</code>
*/
public DOMSignContext(Key signingKey, Node parent) {
if (signingKey == null) {
throw new NullPointerException("signingKey cannot be null");
}
if (parent == null) {
throw new NullPointerException("parent cannot be null");
}
setKeySelector(KeySelector.singletonKeySelector(signingKey));
this.parent = parent;
}
/** {@collect.stats}
* Creates a <code>DOMSignContext</code> with the specified signing key,
* parent and next sibling nodes. The signing key is stored in a
* {@link KeySelector#singletonKeySelector singleton KeySelector} that is
* returned by the {@link #getKeySelector getKeySelector} method.
* The marshalled <code>XMLSignature</code> will be inserted as a child
* element of the specified parent node and immediately before the
* specified next sibling node.
*
* @param signingKey the signing key
* @param parent the parent node
* @param nextSibling the next sibling node
* @throws NullPointerException if <code>signingKey</code>,
* <code>parent</code> or <code>nextSibling</code> is <code>null</code>
*/
public DOMSignContext(Key signingKey, Node parent, Node nextSibling) {
if (signingKey == null) {
throw new NullPointerException("signingKey cannot be null");
}
if (parent == null) {
throw new NullPointerException("parent cannot be null");
}
if (nextSibling == null) {
throw new NullPointerException("nextSibling cannot be null");
}
setKeySelector(KeySelector.singletonKeySelector(signingKey));
this.parent = parent;
this.nextSibling = nextSibling;
}
/** {@collect.stats}
* Creates a <code>DOMSignContext</code> with the specified key selector
* and parent node. The marshalled <code>XMLSignature</code> will be added
* as the last child element of the specified parent node unless a next
* sibling node is specified by invoking the
* {@link #setNextSibling setNextSibling} method.
*
* @param ks the key selector
* @param parent the parent node
* @throws NullPointerException if <code>ks</code> or <code>parent</code>
* is <code>null</code>
*/
public DOMSignContext(KeySelector ks, Node parent) {
if (ks == null) {
throw new NullPointerException("key selector cannot be null");
}
if (parent == null) {
throw new NullPointerException("parent cannot be null");
}
setKeySelector(ks);
this.parent = parent;
}
/** {@collect.stats}
* Creates a <code>DOMSignContext</code> with the specified key selector,
* parent and next sibling nodes. The marshalled <code>XMLSignature</code>
* will be inserted as a child element of the specified parent node and
* immediately before the specified next sibling node.
*
* @param ks the key selector
* @param parent the parent node
* @param nextSibling the next sibling node
* @throws NullPointerException if <code>ks</code>, <code>parent</code> or
* <code>nextSibling</code> is <code>null</code>
*/
public DOMSignContext(KeySelector ks, Node parent, Node nextSibling) {
if (ks == null) {
throw new NullPointerException("key selector cannot be null");
}
if (parent == null) {
throw new NullPointerException("parent cannot be null");
}
if (nextSibling == null) {
throw new NullPointerException("nextSibling cannot be null");
}
setKeySelector(ks);
this.parent = parent;
this.nextSibling = nextSibling;
}
/** {@collect.stats}
* Sets the parent node.
*
* @param parent the parent node. The marshalled <code>XMLSignature</code>
* will be added as a child element of this node.
* @throws NullPointerException if <code>parent</code> is <code>null</code>
* @see #getParent
*/
public void setParent(Node parent) {
if (parent == null) {
throw new NullPointerException("parent is null");
}
this.parent = parent;
}
/** {@collect.stats}
* Sets the next sibling node.
*
* @param nextSibling the next sibling node. The marshalled
* <code>XMLSignature</code> will be inserted immediately before this
* node. Specify <code>null</code> to remove the current setting.
* @see #getNextSibling
*/
public void setNextSibling(Node nextSibling) {
this.nextSibling = nextSibling;
}
/** {@collect.stats}
* Returns the parent node.
*
* @return the parent node (never <code>null</code>)
* @see #setParent(Node)
*/
public Node getParent() {
return parent;
}
/** {@collect.stats}
* Returns the nextSibling node.
*
* @return the nextSibling node, or <code>null</code> if not specified.
* @see #setNextSibling(Node)
*/
public Node getNextSibling() {
return nextSibling;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DOMValidateContext.java,v 1.8 2005/05/10 16:31:14 mullan Exp $
*/
package javax.xml.crypto.dsig.dom;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.XMLValidateContext;
import java.security.Key;
import org.w3c.dom.Node;
/** {@collect.stats}
* A DOM-specific {@link XMLValidateContext}. This class contains additional
* methods to specify the location in a DOM tree where an {@link XMLSignature}
* is to be unmarshalled and validated from.
*
* <p>Note that the behavior of an unmarshalled <code>XMLSignature</code>
* is undefined if the contents of the underlying DOM tree are modified by the
* caller after the <code>XMLSignature</code> is created.
*
* <p>Also, note that <code>DOMValidateContext</code> instances can contain
* information and state specific to the XML signature structure it is
* used with. The results are unpredictable if a
* <code>DOMValidateContext</code> is used with different signature structures
* (for example, you should not use the same <code>DOMValidateContext</code>
* instance to validate two different {@link XMLSignature} objects).
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#unmarshalXMLSignature(XMLValidateContext)
*/
public class DOMValidateContext extends DOMCryptoContext
implements XMLValidateContext {
private Node node;
/** {@collect.stats}
* Creates a <code>DOMValidateContext</code> containing the specified key
* selector and node.
*
* @param ks a key selector for finding a validation key
* @param node the node
* @throws NullPointerException if <code>ks</code> or <code>node</code> is
* <code>null</code>
*/
public DOMValidateContext(KeySelector ks, Node node) {
if (ks == null) {
throw new NullPointerException("key selector is null");
}
if (node == null) {
throw new NullPointerException("node is null");
}
setKeySelector(ks);
this.node = node;
}
/** {@collect.stats}
* Creates a <code>DOMValidateContext</code> containing the specified key
* and node. The validating key will be stored in a
* {@link KeySelector#singletonKeySelector singleton KeySelector} that
* is returned when the {@link #getKeySelector getKeySelector}
* method is called.
*
* @param validatingKey the validating key
* @param node the node
* @throws NullPointerException if <code>validatingKey</code> or
* <code>node</code> is <code>null</code>
*/
public DOMValidateContext(Key validatingKey, Node node) {
if (validatingKey == null) {
throw new NullPointerException("validatingKey is null");
}
if (node == null) {
throw new NullPointerException("node is null");
}
setKeySelector(KeySelector.singletonKeySelector(validatingKey));
this.node = node;
}
/** {@collect.stats}
* Sets the node.
*
* @param node the node
* @throws NullPointerException if <code>node</code> is <code>null</code>
* @see #getNode
*/
public void setNode(Node node) {
if (node == null) {
throw new NullPointerException();
}
this.node = node;
}
/** {@collect.stats}
* Returns the node.
*
* @return the node (never <code>null</code>)
* @see #setNode(Node)
*/
public Node getNode() {
return node;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLSignContext.java,v 1.8 2005/05/10 16:03:48 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.XMLCryptoContext;
/** {@collect.stats}
* Contains context information for generating XML Signatures. This interface
* is primarily intended for type-safety.
*
* <p>Note that <code>XMLSignContext</code> instances can contain
* information and state specific to the XML signature structure it is
* used with. The results are unpredictable if an
* <code>XMLSignContext</code> is used with different signature structures
* (for example, you should not use the same <code>XMLSignContext</code>
* instance to sign two different {@link XMLSignature} objects).
* <p>
* <b><a name="Supported Properties"></a>Supported Properties</b>
* <p>The following properties can be set using the
* {@link #setProperty setProperty} method.
* <ul>
* <li><code>javax.xml.crypto.dsig.cacheReference</code>: value must be a
* {@link Boolean}. This property controls whether or not the digested
* {@link Reference} objects will cache the dereferenced content and
* pre-digested input for subsequent retrieval via the
* {@link Reference#getDereferencedData Reference.getDereferencedData} and
* {@link Reference#getDigestInputStream Reference.getDigestInputStream}
* methods. The default value if not specified is
* <code>Boolean.FALSE</code>.
* </ul>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignature#sign(XMLSignContext)
*/
public interface XMLSignContext extends XMLCryptoContext {}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DigestMethod.java,v 1.6 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* A representation of the XML <code>DigestMethod</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <p>
* <pre>
* <element name="DigestMethod" type="ds:DigestMethodType"/>
* <complexType name="DigestMethodType" mixed="true">
* <sequence>
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
* <!-- (0,unbounded) elements from (1,1) namespace -->
* </sequence>
* <attribute name="Algorithm" type="anyURI" use="required"/>
* </complexType>
* </pre>
*
* A <code>DigestMethod</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newDigestMethod newDigestMethod} method
* of the {@link XMLSignatureFactory} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newDigestMethod(String, DigestMethodParameterSpec)
*/
public interface DigestMethod extends XMLStructure, AlgorithmMethod {
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#sha1">
* SHA1</a> digest method algorithm URI.
*/
static final String SHA1 = "http://www.w3.org/2000/09/xmldsig#sha1";
/** {@collect.stats}
* The <a href="http://www.w3.org/2001/04/xmlenc#sha256">
* SHA256</a> digest method algorithm URI.
*/
static final String SHA256 = "http://www.w3.org/2001/04/xmlenc#sha256";
/** {@collect.stats}
* The <a href="http://www.w3.org/2001/04/xmlenc#sha512">
* SHA512</a> digest method algorithm URI.
*/
static final String SHA512 = "http://www.w3.org/2001/04/xmlenc#sha512";
/** {@collect.stats}
* The <a href="http://www.w3.org/2001/04/xmlenc#ripemd160">
* RIPEMD-160</a> digest method algorithm URI.
*/
static final String RIPEMD160 = "http://www.w3.org/2001/04/xmlenc#ripemd160";
/** {@collect.stats}
* Returns the algorithm-specific input parameters associated with this
* <code>DigestMethod</code>.
*
* <p>The returned parameters can be typecast to a {@link
* DigestMethodParameterSpec} object.
*
* @return the algorithm-specific parameters (may be <code>null</code> if
* not specified)
*/
AlgorithmParameterSpec getParameterSpec();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignatureMethod.java,v 1.5 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* A representation of the XML <code>SignatureMethod</code> element
* as defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <p>
* <pre>
* <element name="SignatureMethod" type="ds:SignatureMethodType"/>
* <complexType name="SignatureMethodType" mixed="true">
* <sequence>
* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
* <!-- (0,unbounded) elements from (1,1) namespace -->
* </sequence>
* <attribute name="Algorithm" type="anyURI" use="required"/>
* </complexType>
* </pre>
*
* A <code>SignatureMethod</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newSignatureMethod newSignatureMethod} method
* of the {@link XMLSignatureFactory} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newSignatureMethod(String, SignatureMethodParameterSpec)
*/
public interface SignatureMethod extends XMLStructure, AlgorithmMethod {
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#dsa-sha1">DSAwithSHA1</a>
* (DSS) signature method algorithm URI.
*/
static final String DSA_SHA1 =
"http://www.w3.org/2000/09/xmldsig#dsa-sha1";
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#rsa-sha1">RSAwithSHA1</a>
* (PKCS #1) signature method algorithm URI.
*/
static final String RSA_SHA1 =
"http://www.w3.org/2000/09/xmldsig#rsa-sha1";
/** {@collect.stats}
* The <a href="http://www.w3.org/2000/09/xmldsig#hmac-sha1">HMAC-SHA1</a>
* MAC signature method algorithm URI
*/
static final String HMAC_SHA1 =
"http://www.w3.org/2000/09/xmldsig#hmac-sha1";
/** {@collect.stats}
* Returns the algorithm-specific input parameters of this
* <code>SignatureMethod</code>.
*
* <p>The returned parameters can be typecast to a {@link
* SignatureMethodParameterSpec} object.
*
* @return the algorithm-specific input parameters of this
* <code>SignatureMethod</code> (may be <code>null</code> if not
* specified)
*/
AlgorithmParameterSpec getParameterSpec();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignedInfo.java,v 1.7 2005/05/10 16:03:47 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.XMLStructure;
import java.io.InputStream;
import java.util.List;
/** {@collect.stats}
* An representation of the XML <code>SignedInfo</code> element as
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <pre><code>
* <element name="SignedInfo" type="ds:SignedInfoType"/>
* <complexType name="SignedInfoType">
* <sequence>
* <element ref="ds:CanonicalizationMethod"/>
* <element ref="ds:SignatureMethod"/>
* <element ref="ds:Reference" maxOccurs="unbounded"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* </complexType>
* </code></pre>
*
* A <code>SignedInfo</code> instance may be created by invoking one of the
* {@link XMLSignatureFactory#newSignedInfo newSignedInfo} methods of the
* {@link XMLSignatureFactory} class.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newSignedInfo(CanonicalizationMethod, SignatureMethod, List)
* @see XMLSignatureFactory#newSignedInfo(CanonicalizationMethod, SignatureMethod, List, String)
*/
public interface SignedInfo extends XMLStructure {
/** {@collect.stats}
* Returns the canonicalization method of this <code>SignedInfo</code>.
*
* @return the canonicalization method
*/
CanonicalizationMethod getCanonicalizationMethod();
/** {@collect.stats}
* Returns the signature method of this <code>SignedInfo</code>.
*
* @return the signature method
*/
SignatureMethod getSignatureMethod();
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList
* unmodifiable list} of one or more {@link Reference}s.
*
* @return an unmodifiable list of one or more {@link Reference}s
*/
List getReferences();
/** {@collect.stats}
* Returns the optional <code>Id</code> attribute of this
* <code>SignedInfo</code>.
*
* @return the id (may be <code>null</code> if not specified)
*/
String getId();
/** {@collect.stats}
* Returns the canonicalized signed info bytes after a signing or
* validation operation. This method is useful for debugging.
*
* @return an <code>InputStream</code> containing the canonicalized bytes,
* or <code>null</code> if this <code>SignedInfo</code> has not been
* signed or validated yet
*/
InputStream getCanonicalizedData();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: Reference.java,v 1.9 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.Data;
import javax.xml.crypto.URIReference;
import javax.xml.crypto.XMLStructure;
import java.io.InputStream;
import java.util.List;
/** {@collect.stats}
* A representation of the <code>Reference</code> element as defined in the
* <a href="http://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML schema is defined as:
* <code><pre>
* <element name="Reference" type="ds:ReferenceType"/>
* <complexType name="ReferenceType">
* <sequence>
* <element ref="ds:Transforms" minOccurs="0"/>
* <element ref="ds:DigestMethod"/>
* <element ref="ds:DigestValue"/>
* </sequence>
* <attribute name="Id" type="ID" use="optional"/>
* <attribute name="URI" type="anyURI" use="optional"/>
* <attribute name="Type" type="anyURI" use="optional"/>
* </complexType>
*
* <element name="DigestValue" type="ds:DigestValueType"/>
* <simpleType name="DigestValueType">
* <restriction base="base64Binary"/>
* </simpleType>
* </pre></code>
*
* <p>A <code>Reference</code> instance may be created by invoking one of the
* {@link XMLSignatureFactory#newReference newReference} methods of the
* {@link XMLSignatureFactory} class; for example:
*
* <pre>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* Reference ref = factory.newReference
* ("http://www.ietf.org/rfc/rfc3275.txt",
* factory.newDigestMethod(DigestMethod.SHA1, null));
* </pre>
*
* @author Sean Mullan
* @author Erwin van der Koogh
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newReference(String, DigestMethod)
* @see XMLSignatureFactory#newReference(String, DigestMethod, List, String, String)
*/
public interface Reference extends URIReference, XMLStructure {
/** {@collect.stats}
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
* list} of {@link Transform}s that are contained in this
* <code>Reference</code>.
*
* @return an unmodifiable list of <code>Transform</code>s
* (may be empty but never <code>null</code>)
*/
List getTransforms();
/** {@collect.stats}
* Returns the digest method of this <code>Reference</code>.
*
* @return the digest method
*/
DigestMethod getDigestMethod();
/** {@collect.stats}
* Returns the optional <code>Id</code> attribute of this
* <code>Reference</code>, which permits this reference to be
* referenced from elsewhere.
*
* @return the <code>Id</code> attribute (may be <code>null</code> if not
* specified)
*/
String getId();
/** {@collect.stats}
* Returns the digest value of this <code>Reference</code>.
*
* @return the raw digest value, or <code>null</code> if this reference has
* not been digested yet. Each invocation of this method returns a new
* clone to protect against subsequent modification.
*/
byte[] getDigestValue();
/** {@collect.stats}
* Returns the calculated digest value of this <code>Reference</code>
* after a validation operation. This method is useful for debugging if
* the reference fails to validate.
*
* @return the calculated digest value, or <code>null</code> if this
* reference has not been validated yet. Each invocation of this method
* returns a new clone to protect against subsequent modification.
*/
byte[] getCalculatedDigestValue();
/** {@collect.stats}
* Validates this reference. This method verifies the digest of this
* reference.
*
* <p>This method only validates the reference the first time it is
* invoked. On subsequent invocations, it returns a cached result.
*
* @return <code>true</code> if this reference was validated successfully;
* <code>false</code> otherwise
* @param validateContext the validating context
* @throws NullPointerException if <code>validateContext</code> is
* <code>null</code>
* @throws XMLSignatureException if an unexpected exception occurs while
* validating the reference
*/
boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException;
/** {@collect.stats}
* Returns the dereferenced data, if
* <a href="XMLSignContext.html#Supported Properties">reference caching</a>
* is enabled. This is the result of dereferencing the URI of this
* reference during a validation or generation operation.
*
* @return the dereferenced data, or <code>null</code> if reference
* caching is not enabled or this reference has not been generated or
* validated
*/
Data getDereferencedData();
/** {@collect.stats}
* Returns the pre-digested input stream, if
* <a href="XMLSignContext.html#Supported Properties">reference caching</a>
* is enabled. This is the input to the digest operation during a
* validation or signing operation.
*
* @return an input stream containing the pre-digested input, or
* <code>null</code> if reference caching is not enabled or this
* reference has not been generated or validated
*/
InputStream getDigestInputStream();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: MarshalException.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.io.PrintStream;
import java.io.PrintWriter;
import javax.xml.crypto.dsig.Manifest;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
/** {@collect.stats}
* Indicates an exceptional condition that occured during the XML
* marshalling or unmarshalling process.
*
* <p>A <code>MarshalException</code> can contain a cause: another
* throwable that caused this <code>MarshalException</code> to get thrown.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignature#sign(XMLSignContext)
* @see XMLSignatureFactory#unmarshalXMLSignature(XMLValidateContext)
*/
public class MarshalException extends Exception {
private static final long serialVersionUID = -863185580332643547L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or null if this
* exception was not caused by another throwable or if the causative
* throwable is unknown.
*
* @serial
*/
private Throwable cause;
/** {@collect.stats}
* Constructs a new <code>MarshalException</code> with
* <code>null</code> as its detail message.
*/
public MarshalException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>MarshalException</code> with the specified
* detail message.
*
* @param message the detail message
*/
public MarshalException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>MarshalException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public MarshalException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>MarshalException</code> with the specified cause
* and a detail message of <code>(cause==null ? null : cause.toString())
* </code> (which typically contains the class and detail message of
* <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public MarshalException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the cause of this <code>MarshalException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>MarshalException</code> to get thrown.)
*
* @return the cause of this <code>MarshalException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>MarshalException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>MarshalException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>MarshalException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
*
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
*
* ===========================================================================
*/
/*
* $Id: URIDereferencer.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
/** {@collect.stats}
* A dereferencer of {@link URIReference}s.
* <p>
* The result of dereferencing a <code>URIReference</code> is either an
* instance of {@link OctetStreamData} or {@link NodeSetData}. Unless the
* <code>URIReference</code> is a <i>same-document reference</i> as defined
* in section 4.2 of the W3C Recommendation for XML-Signature Syntax and
* Processing, the result of dereferencing the <code>URIReference</code>
* MUST be an <code>OctetStreamData</code>.
*
* @author Sean Mullan
* @author Joyce Leung
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLCryptoContext#setURIDereferencer(URIDereferencer)
* @see XMLCryptoContext#getURIDereferencer
*/
public interface URIDereferencer {
/** {@collect.stats}
* Dereferences the specified <code>URIReference</code> and returns the
* dereferenced data.
*
* @param uriReference the <code>URIReference</code>
* @param context an <code>XMLCryptoContext</code> that may
* contain additional useful information for dereferencing the URI. This
* implementation should dereference the specified
* <code>URIReference</code> against the context's <code>baseURI</code>
* parameter, if specified.
* @return the dereferenced data
* @throws NullPointerException if <code>uriReference</code> or
* <code>context</code> are <code>null</code>
* @throws URIReferenceException if an exception occurs while
* dereferencing the specified <code>uriReference</code>
*/
Data dereference(URIReference uriReference, XMLCryptoContext context)
throws URIReferenceException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeySelectorException.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.io.PrintStream;
import java.io.PrintWriter;
/** {@collect.stats}
* Indicates an exceptional condition thrown by a {@link KeySelector}.
*
* <p>A <code>KeySelectorException</code> can contain a cause: another
* throwable that caused this <code>KeySelectorException</code> to get thrown.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public class KeySelectorException extends Exception {
private static final long serialVersionUID = -7480033639322531109L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or
* <code>null</code> if this exception was not caused by another throwable
* or if the causative throwable is unknown.
*
* @serial
*/
private Throwable cause;
/** {@collect.stats}
* Constructs a new <code>KeySelectorException</code> with
* <code>null</code> as its detail message.
*/
public KeySelectorException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>KeySelectorException</code> with the specified
* detail message.
*
* @param message the detail message
*/
public KeySelectorException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>KeySelectorException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public KeySelectorException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>KeySelectorException</code> with the specified
* cause and a detail message of
* <code>(cause==null ? null : cause.toString())</code>
* (which typically contains the class and detail message of
* <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public KeySelectorException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the cause of this <code>KeySelectorException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>KeySelectorException</code> to get thrown.)
*
* @return the cause of this <code>KeySelectorException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>KeySelectorException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>KeySelectorException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>KeySelectorException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: AlgorithmMethod.java,v 1.4 2005/05/10 15:47:41 mullan Exp $
*/
package javax.xml.crypto;
import java.security.spec.AlgorithmParameterSpec;
/** {@collect.stats}
* An abstract representation of an algorithm defined in the XML Security
* specifications. Subclasses represent specific types of XML security
* algorithms, such as a {@link javax.xml.crypto.dsig.Transform}.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface AlgorithmMethod {
/** {@collect.stats}
* Returns the algorithm URI of this <code>AlgorithmMethod</code>.
*
* @return the algorithm URI of this <code>AlgorithmMethod</code>
*/
String getAlgorithm();
/** {@collect.stats}
* Returns the algorithm parameters of this <code>AlgorithmMethod</code>.
*
* @return the algorithm parameters of this <code>AlgorithmMethod</code>.
* Returns <code>null</code> if this <code>AlgorithmMethod</code> does
* not require parameters and they are not specified.
*/
AlgorithmParameterSpec getParameterSpec();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: KeySelector.java,v 1.6 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.security.Key;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
/** {@collect.stats}
* A selector that finds and returns a key using the data contained in a
* {@link KeyInfo} object. An example of an implementation of
* this class is one that searchs a {@link java.security.KeyStore} for
* trusted keys that match information contained in a <code>KeyInfo</code>.
*
* <p>Whether or not the returned key is trusted and the mechanisms
* used to determine that is implementation-specific.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public abstract class KeySelector {
/** {@collect.stats}
* The purpose of the key that is to be selected.
*/
public static class Purpose {
private final String name;
private Purpose(String name) { this.name = name; }
/** {@collect.stats}
* Returns a string representation of this purpose ("sign",
* "verify", "encrypt", or "decrypt").
*
* @return a string representation of this purpose
*/
public String toString() { return name; }
/** {@collect.stats}
* A key for signing.
*/
public static final Purpose SIGN = new Purpose("sign");
/** {@collect.stats}
* A key for verifying.
*/
public static final Purpose VERIFY = new Purpose("verify");
/** {@collect.stats}
* A key for encrypting.
*/
public static final Purpose ENCRYPT = new Purpose("encrypt");
/** {@collect.stats}
* A key for decrypting.
*/
public static final Purpose DECRYPT = new Purpose("decrypt");
}
/** {@collect.stats}
* Default no-args constructor; intended for invocation by subclasses only.
*/
protected KeySelector() {}
/** {@collect.stats}
* Attempts to find a key that satisfies the specified constraints.
*
* @param keyInfo a <code>KeyInfo</code> (may be <code>null</code>)
* @param purpose the key's purpose ({@link Purpose#SIGN},
* {@link Purpose#VERIFY}, {@link Purpose#ENCRYPT}, or
* {@link Purpose#DECRYPT})
* @param method the algorithm method that this key is to be used for.
* Only keys that are compatible with the algorithm and meet the
* constraints of the specified algorithm should be returned.
* @param context an <code>XMLCryptoContext</code> that may contain
* useful information for finding an appropriate key. If this key
* selector supports resolving {@link RetrievalMethod} types, the
* context's <code>baseURI</code> and <code>dereferencer</code>
* parameters (if specified) should be used by the selector to
* resolve and dereference the URI.
* @return the result of the key selector
* @throws KeySelectorException if an exceptional condition occurs while
* attempting to find a key. Note that an inability to find a key is not
* considered an exception (<code>null</code> should be
* returned in that case). However, an error condition (ex: network
* communications failure) that prevented the <code>KeySelector</code>
* from finding a potential key should be considered an exception.
* @throws ClassCastException if the data type of <code>method</code>
* is not supported by this key selector
*/
public abstract KeySelectorResult select(KeyInfo keyInfo, Purpose purpose,
AlgorithmMethod method, XMLCryptoContext context)
throws KeySelectorException;
/** {@collect.stats}
* Returns a <code>KeySelector</code> that always selects the specified
* key, regardless of the <code>KeyInfo</code> passed to it.
*
* @param key the sole key to be stored in the key selector
* @return a key selector that always selects the specified key
* @throws NullPointerException if <code>key</code> is <code>null</code>
*/
public static KeySelector singletonKeySelector(Key key) {
return new SingletonKeySelector(key);
}
private static class SingletonKeySelector extends KeySelector {
private final Key key;
SingletonKeySelector(Key key) {
if (key == null) {
throw new NullPointerException();
}
this.key = key;
}
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose,
AlgorithmMethod method, XMLCryptoContext context)
throws KeySelectorException {
return new KeySelectorResult() {
public Key getKey() {
return key;
}
};
}
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLStructure.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
/** {@collect.stats}
* A representation of an XML structure from any namespace. The purpose of
* this interface is to group (and provide type safety for) all
* representations of XML structures.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface XMLStructure {
/** {@collect.stats}
* Indicates whether a specified feature is supported.
*
* @param feature the feature name (as an absolute URI)
* @return <code>true</code> if the specified feature is supported,
* <code>false</code> otherwise
* @throws NullPointerException if <code>feature</code> is <code>null</code>
*/
boolean isFeatureSupported(String feature);
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: URIReferenceException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.io.PrintStream;
import java.io.PrintWriter;
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
/** {@collect.stats}
* Indicates an exceptional condition thrown while dereferencing a
* {@link URIReference}.
*
* <p>A <code>URIReferenceException</code> can contain a cause: another
* throwable that caused this <code>URIReferenceException</code> to get thrown.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see URIDereferencer#dereference(URIReference, XMLCryptoContext)
* @see RetrievalMethod#dereference(XMLCryptoContext)
*/
public class URIReferenceException extends Exception {
private static final long serialVersionUID = 7173469703932561419L;
/** {@collect.stats}
* The throwable that caused this exception to get thrown, or null if this
* exception was not caused by another throwable or if the causative
* throwable is unknown.
*
* @serial
*/
private Throwable cause;
private URIReference uriReference;
/** {@collect.stats}
* Constructs a new <code>URIReferenceException</code> with
* <code>null</code> as its detail message.
*/
public URIReferenceException() {
super();
}
/** {@collect.stats}
* Constructs a new <code>URIReferenceException</code> with the specified
* detail message.
*
* @param message the detail message
*/
public URIReferenceException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new <code>URIReferenceException</code> with the
* specified detail message and cause.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public URIReferenceException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
/** {@collect.stats}
* Constructs a new <code>URIReferenceException</code> with the
* specified detail message, cause and <code>URIReference</code>.
* <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
* @param uriReference the <code>URIReference</code> that was being
* dereferenced when the error was encountered
* @throws NullPointerException if <code>uriReference</code> is
* <code>null</code>
*/
public URIReferenceException(String message, Throwable cause,
URIReference uriReference) {
this(message, cause);
if (uriReference == null) {
throw new NullPointerException("uriReference cannot be null");
}
this.uriReference = uriReference;
}
/** {@collect.stats}
* Constructs a new <code>URIReferenceException</code> with the specified
* cause and a detail message of <code>(cause==null ? null :
* cause.toString())</code> (which typically contains the class and detail
* message of <code>cause</code>).
*
* @param cause the cause (A <tt>null</tt> value is permitted, and
* indicates that the cause is nonexistent or unknown.)
*/
public URIReferenceException(Throwable cause) {
super(cause==null ? null : cause.toString());
this.cause = cause;
}
/** {@collect.stats}
* Returns the <code>URIReference</code> that was being dereferenced
* when the exception was thrown.
*
* @return the <code>URIReference</code> that was being dereferenced
* when the exception was thrown, or <code>null</code> if not specified
*/
public URIReference getURIReference() {
return uriReference;
}
/** {@collect.stats}
* Returns the cause of this <code>URIReferenceException</code> or
* <code>null</code> if the cause is nonexistent or unknown. (The
* cause is the throwable that caused this
* <code>URIReferenceException</code> to get thrown.)
*
* @return the cause of this <code>URIReferenceException</code> or
* <code>null</code> if the cause is nonexistent or unknown.
*/
public Throwable getCause() {
return cause;
}
/** {@collect.stats}
* Prints this <code>URIReferenceException</code>, its backtrace and
* the cause's backtrace to the standard error stream.
*/
public void printStackTrace() {
super.printStackTrace();
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>URIReferenceException</code>, its backtrace and
* the cause's backtrace to the specified print stream.
*
* @param s <code>PrintStream</code> to use for output
*/
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
/** {@collect.stats}
* Prints this <code>URIReferenceException</code>, its backtrace and
* the cause's backtrace to the specified print writer.
*
* @param s <code>PrintWriter</code> to use for output
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
//XXX print backtrace of cause
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: XMLCryptoContext.java,v 1.6 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
/** {@collect.stats}
* Contains common context information for XML cryptographic operations.
*
* <p>This interface contains methods for setting and retrieving properties
* that affect the processing of XML signatures or XML encrypted structures.
*
* <p>Note that <code>XMLCryptoContext</code> instances can contain information
* and state specific to the XML cryptographic structure it is used with.
* The results are unpredictable if an <code>XMLCryptoContext</code> is
* used with multiple structures (for example, you should not use the same
* {@link javax.xml.crypto.dsig.XMLValidateContext} instance to validate two
* different {@link javax.xml.crypto.dsig.XMLSignature} objects).
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface XMLCryptoContext {
/** {@collect.stats}
* Returns the base URI.
*
* @return the base URI, or <code>null</code> if not specified
* @see #setBaseURI(String)
*/
String getBaseURI();
/** {@collect.stats}
* Sets the base URI.
*
* @param baseURI the base URI, or <code>null</code> to remove current
* value
* @throws IllegalArgumentException if <code>baseURI</code> is not RFC
* 2396 compliant
* @see #getBaseURI
*/
void setBaseURI(String baseURI);
/** {@collect.stats}
* Returns the key selector for finding a key.
*
* @return the key selector, or <code>null</code> if not specified
* @see #setKeySelector(KeySelector)
*/
KeySelector getKeySelector();
/** {@collect.stats}
* Sets the key selector for finding a key.
*
* @param ks the key selector, or <code>null</code> to remove the current
* setting
* @see #getKeySelector
*/
void setKeySelector(KeySelector ks);
/** {@collect.stats}
* Returns a <code>URIDereferencer</code> that is used to dereference
* {@link URIReference}s.
*
* @return the <code>URIDereferencer</code>, or <code>null</code> if not
* specified
* @see #setURIDereferencer(URIDereferencer)
*/
URIDereferencer getURIDereferencer();
/** {@collect.stats}
* Sets a <code>URIDereferencer</code> that is used to dereference
* {@link URIReference}s. The specified <code>URIDereferencer</code>
* is used in place of an implementation's default
* <code>URIDereferencer</code>.
*
* @param dereferencer the <code>URIDereferencer</code>, or
* <code>null</code> to remove any current setting
* @see #getURIDereferencer
*/
void setURIDereferencer(URIDereferencer dereferencer);
/** {@collect.stats}
* Returns the namespace prefix that the specified namespace URI is
* associated with. Returns the specified default prefix if the specified
* namespace URI has not been bound to a prefix. To bind a namespace URI
* to a prefix, call the {@link #putNamespacePrefix putNamespacePrefix}
* method.
*
* @param namespaceURI a namespace URI
* @param defaultPrefix the prefix to be returned in the event that the
* the specified namespace URI has not been bound to a prefix.
* @return the prefix that is associated with the specified namespace URI,
* or <code>defaultPrefix</code> if the URI is not registered. If
* the namespace URI is registered but has no prefix, an empty string
* (<code>""</code>) is returned.
* @throws NullPointerException if <code>namespaceURI</code> is
* <code>null</code>
* @see #putNamespacePrefix(String, String)
*/
String getNamespacePrefix(String namespaceURI, String defaultPrefix);
/** {@collect.stats}
* Maps the specified namespace URI to the specified prefix. If there is
* already a prefix associated with the specified namespace URI, the old
* prefix is replaced by the specified prefix.
*
* @param namespaceURI a namespace URI
* @param prefix a namespace prefix (or <code>null</code> to remove any
* existing mapping). Specifying the empty string (<code>""</code>)
* binds no prefix to the namespace URI.
* @return the previous prefix associated with the specified namespace
* URI, or <code>null</code> if there was none
* @throws NullPointerException if <code>namespaceURI</code> is
* <code>null</code>
* @see #getNamespacePrefix(String, String)
*/
String putNamespacePrefix(String namespaceURI, String prefix);
/** {@collect.stats}
* Returns the default namespace prefix. The default namespace prefix
* is the prefix for all namespace URIs not explicitly set by the
* {@link #putNamespacePrefix putNamespacePrefix} method.
*
* @return the default namespace prefix, or <code>null</code> if none has
* been set.
* @see #setDefaultNamespacePrefix(String)
*/
String getDefaultNamespacePrefix();
/** {@collect.stats}
* Sets the default namespace prefix. This sets the namespace prefix for
* all namespace URIs not explicitly set by the {@link #putNamespacePrefix
* putNamespacePrefix} method.
*
* @param defaultPrefix the default namespace prefix, or <code>null</code>
* to remove the current setting. Specify the empty string
* (<code>""</code>) to bind no prefix.
* @see #getDefaultNamespacePrefix
*/
void setDefaultNamespacePrefix(String defaultPrefix);
/** {@collect.stats}
* Sets the specified property.
*
* @param name the name of the property
* @param value the value of the property to be set
* @return the previous value of the specified property, or
* <code>null</code> if it did not have a value
* @throws NullPointerException if <code>name</code> is <code>null</code>
* @see #getProperty(String)
*/
Object setProperty(String name, Object value);
/** {@collect.stats}
* Returns the value of the specified property.
*
* @param name the name of the property
* @return the current value of the specified property, or
* <code>null</code> if it does not have a value
* @throws NullPointerException if <code>name</code> is <code>null</code>
* @see #setProperty(String, Object)
*/
Object getProperty(String name);
/** {@collect.stats}
* Returns the value to which this context maps the specified key.
*
* <p>More formally, if this context contains a mapping from a key
* <code>k</code> to a value <code>v</code> such that
* <code>(key==null ? k==null : key.equals(k))</code>, then this method
* returns <code>v</code>; otherwise it returns <code>null</code>. (There
* can be at most one such mapping.)
*
* <p>This method is useful for retrieving arbitrary information that is
* specific to the cryptographic operation that this context is used for.
*
* @param key the key whose associated value is to be returned
* @return the value to which this context maps the specified key, or
* <code>null</code> if there is no mapping for the key
* @see #put(Object, Object)
*/
Object get(Object key);
/** {@collect.stats}
* Associates the specified value with the specified key in this context.
* If the context previously contained a mapping for this key, the old
* value is replaced by the specified value.
*
* <p>This method is useful for storing arbitrary information that is
* specific to the cryptographic operation that this context is used for.
*
* @param key key with which the specified value is to be associated with
* @param value value to be associated with the specified key
* @return the previous value associated with the key, or <code>null</code>
* if there was no mapping for the key
* @throws IllegalArgumentException if some aspect of this key or value
* prevents it from being stored in this context
* @see #get(Object)
*/
Object put(Object key, Object value);
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: OctetStreamData.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.io.InputStream;
/** {@collect.stats}
* A representation of a <code>Data</code> type containing an octet stream.
*
* @since 1.6
*/
public class OctetStreamData implements Data {
private InputStream octetStream;
private String uri;
private String mimeType;
/** {@collect.stats}
* Creates a new <code>OctetStreamData</code>.
*
* @param octetStream the input stream containing the octets
* @throws NullPointerException if <code>octetStream</code> is
* <code>null</code>
*/
public OctetStreamData(InputStream octetStream) {
if (octetStream == null) {
throw new NullPointerException("octetStream is null");
}
this.octetStream = octetStream;
}
/** {@collect.stats}
* Creates a new <code>OctetStreamData</code>.
*
* @param octetStream the input stream containing the octets
* @param uri the URI String identifying the data object (may be
* <code>null</code>)
* @param mimeType the MIME type associated with the data object (may be
* <code>null</code>)
* @throws NullPointerException if <code>octetStream</code> is
* <code>null</code>
*/
public OctetStreamData(InputStream octetStream, String uri,
String mimeType) {
if (octetStream == null) {
throw new NullPointerException("octetStream is null");
}
this.octetStream = octetStream;
this.uri = uri;
this.mimeType = mimeType;
}
/** {@collect.stats}
* Returns the input stream of this <code>OctetStreamData</code>.
*
* @return the input stream of this <code>OctetStreamData</code>.
*/
public InputStream getOctetStream() {
return octetStream;
}
/** {@collect.stats}
* Returns the URI String identifying the data object represented by this
* <code>OctetStreamData</code>.
*
* @return the URI String or <code>null</code> if not applicable
*/
public String getURI() {
return uri;
}
/** {@collect.stats}
* Returns the MIME type associated with the data object represented by this
* <code>OctetStreamData</code>.
*
* @return the MIME type or <code>null</code> if not applicable
*/
public String getMimeType() {
return mimeType;
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DOMURIReference.java,v 1.5 2005/05/09 18:33:26 mullan Exp $
*/
package javax.xml.crypto.dom;
import javax.xml.crypto.URIReference;
import org.w3c.dom.Node;
/** {@collect.stats}
* A DOM-specific {@link URIReference}. The purpose of this class is to
* provide additional context necessary for resolving XPointer URIs or
* same-document references.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface DOMURIReference extends URIReference {
/** {@collect.stats}
* Returns the here node.
*
* @return the attribute or processing instruction node or the
* parent element of the text node that directly contains the URI
*/
Node getHere();
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DOMStructure.java,v 1.6 2005/05/09 18:33:26 mullan Exp $
*/
package javax.xml.crypto.dom;
import org.w3c.dom.Node;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.XMLSignature;
/** {@collect.stats}
* A DOM-specific {@link XMLStructure}. The purpose of this class is to
* allow a DOM node to be used to represent extensible content (any elements
* or mixed content) in XML Signature structures.
*
* <p>If a sequence of nodes is needed, the node contained in the
* <code>DOMStructure</code> is the first node of the sequence and successive
* nodes can be accessed by invoking {@link Node#getNextSibling}.
*
* <p>If the owner document of the <code>DOMStructure</code> is different than
* the target document of an <code>XMLSignature</code>, the
* {@link XMLSignature#sign(XMLSignContext)} method imports the node into the
* target document before generating the signature.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public class DOMStructure implements XMLStructure {
private final Node node;
/** {@collect.stats}
* Creates a <code>DOMStructure</code> containing the specified node.
*
* @param node the node
* @throws NullPointerException if <code>node</code> is <code>null</code>
*/
public DOMStructure(Node node) {
if (node == null) {
throw new NullPointerException("node cannot be null");
}
this.node = node;
}
/** {@collect.stats}
* Returns the node contained in this <code>DOMStructure</code>.
*
* @return the node
*/
public Node getNode() {
return node;
}
/** {@collect.stats}
* @throws NullPointerException {@inheritDoc}
*/
public boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
} else {
return false;
}
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: DOMCryptoContext.java,v 1.3 2005/05/09 18:33:26 mullan Exp $
*/
package javax.xml.crypto.dom;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.URIDereferencer;
import javax.xml.crypto.XMLCryptoContext;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import org.w3c.dom.Element;
/** {@collect.stats}
* This class provides a DOM-specific implementation of the
* {@link XMLCryptoContext} interface. It also includes additional
* methods that are specific to a DOM-based implementation for registering
* and retrieving elements that contain attributes of type ID.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public class DOMCryptoContext implements XMLCryptoContext {
private HashMap nsMap = new HashMap();
private HashMap idMap = new HashMap();
private HashMap objMap = new HashMap();
private String baseURI;
private KeySelector ks;
private URIDereferencer dereferencer;
private HashMap propMap = new HashMap();
private String defaultPrefix;
/** {@collect.stats}
* Default constructor. (For invocation by subclass constructors).
*/
protected DOMCryptoContext() {}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to get the prefix
* that the specified URI maps to. It returns the <code>defaultPrefix</code>
* if it maps to <code>null</code>.
*
* @throws NullPointerException {@inheritDoc}
*/
public String getNamespacePrefix(String namespaceURI,
String defaultPrefix) {
if (namespaceURI == null) {
throw new NullPointerException("namespaceURI cannot be null");
}
String prefix = (String) nsMap.get(namespaceURI);
return (prefix != null ? prefix : defaultPrefix);
}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to map the URI
* to the specified prefix.
*
* @throws NullPointerException {@inheritDoc}
*/
public String putNamespacePrefix(String namespaceURI, String prefix) {
if (namespaceURI == null) {
throw new NullPointerException("namespaceURI is null");
}
return (String) nsMap.put(namespaceURI, prefix);
}
public String getDefaultNamespacePrefix() {
return defaultPrefix;
}
public void setDefaultNamespacePrefix(String defaultPrefix) {
this.defaultPrefix = defaultPrefix;
}
public String getBaseURI() {
return baseURI;
}
/** {@collect.stats}
* @throws IllegalArgumentException {@inheritDoc}
*/
public void setBaseURI(String baseURI) {
if (baseURI != null) {
java.net.URI.create(baseURI);
}
this.baseURI = baseURI;
}
public URIDereferencer getURIDereferencer() {
return dereferencer;
}
public void setURIDereferencer(URIDereferencer dereferencer) {
this.dereferencer = dereferencer;
}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to get the object
* that the specified name maps to.
*
* @throws NullPointerException {@inheritDoc}
*/
public Object getProperty(String name) {
if (name == null) {
throw new NullPointerException("name is null");
}
return propMap.get(name);
}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to map the name
* to the specified object.
*
* @throws NullPointerException {@inheritDoc}
*/
public Object setProperty(String name, Object value) {
if (name == null) {
throw new NullPointerException("name is null");
}
return propMap.put(name, value);
}
public KeySelector getKeySelector() {
return ks;
}
public void setKeySelector(KeySelector ks) {
this.ks = ks;
}
/** {@collect.stats}
* Returns the <code>Element</code> with the specified ID attribute value.
*
* <p>This implementation uses an internal {@link HashMap} to get the
* element that the specified attribute value maps to.
*
* @param idValue the value of the ID
* @return the <code>Element</code> with the specified ID attribute value,
* or <code>null</code> if none.
* @throws NullPointerException if <code>idValue</code> is <code>null</code>
* @see #setIdAttributeNS
*/
public Element getElementById(String idValue) {
if (idValue == null) {
throw new NullPointerException("idValue is null");
}
return (Element) idMap.get(idValue);
}
/** {@collect.stats}
* Registers the element's attribute specified by the namespace URI and
* local name to be of type ID. The attribute must have a non-empty value.
*
* <p>This implementation uses an internal {@link HashMap} to map the
* attribute's value to the specified element.
*
* @param element the element
* @param namespaceURI the namespace URI of the attribute (specify
* <code>null</code> if not applicable)
* @param localName the local name of the attribute
* @throws IllegalArgumentException if <code>localName</code> is not an
* attribute of the specified element or it does not contain a specific
* value
* @throws NullPointerException if <code>element</code> or
* <code>localName</code> is <code>null</code>
* @see #getElementById
*/
public void setIdAttributeNS(Element element, String namespaceURI,
String localName) {
if (element == null) {
throw new NullPointerException("element is null");
}
if (localName == null) {
throw new NullPointerException("localName is null");
}
String idValue = element.getAttributeNS(namespaceURI, localName);
if (idValue == null || idValue.length() == 0) {
throw new IllegalArgumentException(localName + " is not an " +
"attribute");
}
idMap.put(idValue, element);
}
/** {@collect.stats}
* Returns a read-only iterator over the set of Id/Element mappings of
* this <code>DOMCryptoContext</code>. Attempts to modify the set via the
* {@link Iterator#remove} method throw an
* <code>UnsupportedOperationException</code>. The mappings are returned
* in no particular order. Each element in the iteration is represented as a
* {@link java.util.Map.Entry}. If the <code>DOMCryptoContext</code> is
* modified while an iteration is in progress, the results of the
* iteration are undefined.
*
* @return a read-only iterator over the set of mappings
*/
public Iterator iterator() {
return Collections.unmodifiableMap(idMap).entrySet().iterator();
}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to get the object
* that the specified key maps to.
*/
public Object get(Object key) {
return objMap.get(key);
}
/** {@collect.stats}
* This implementation uses an internal {@link HashMap} to map the key
* to the specified object.
*
* @throws IllegalArgumentException {@inheritDoc}
*/
public Object put(Object key, Object value) {
return objMap.put(key, value);
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: NodeSetData.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
*/
package javax.xml.crypto;
import java.util.Iterator;
/** {@collect.stats}
* An abstract representation of a <code>Data</code> type containing a
* node-set. The type (class) and ordering of the nodes contained in the set
* are not defined by this class; instead that behavior should be
* defined by <code>NodeSetData</code> subclasses.
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
*/
public interface NodeSetData extends Data {
/** {@collect.stats}
* Returns a read-only iterator over the nodes contained in this
* <code>NodeSetData</code> in
* <a href="http://www.w3.org/TR/1999/REC-xpath-19991116#dt-document-order">
* document order</a>. Attempts to modify the returned iterator
* via the <code>remove</code> method throw
* <code>UnsupportedOperationException</code>.
*
* @return an <code>Iterator</code> over the nodes in this
* <code>NodeSetData</code> in document order
*/
Iterator iterator();
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.Arrays;
/** {@collect.stats}
* A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional
* body and a two byte trailer.
* This class does not attempt to verify that the APDU encodes a semantically
* valid response.
*
* <p>Instances of this class are immutable. Where data is passed in or out
* via byte arrays, defensive cloning is performed.
*
* @see CommandAPDU
* @see CardChannel#transmit CardChannel.transmit
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public final class ResponseAPDU implements java.io.Serializable {
private static final long serialVersionUID = 6962744978375594225L;
/** {@collect.stats} @serial */
private byte[] apdu;
/** {@collect.stats}
* Constructs a ResponseAPDU from a byte array containing the complete
* APDU contents (conditional body and trailed).
*
* <p>Note that the byte array is cloned to protect against subsequent
* modification.
*
* @param apdu the complete response APDU
*
* @throws NullPointerException if apdu is null
* @throws IllegalArgumentException if apdu.length is less than 2
*/
public ResponseAPDU(byte[] apdu) {
apdu = apdu.clone();
check(apdu);
this.apdu = apdu;
}
private static void check(byte[] apdu) {
if (apdu.length < 2) {
throw new IllegalArgumentException("apdu must be at least 2 bytes long");
}
}
/** {@collect.stats}
* Returns the number of data bytes in the response body (Nr) or 0 if this
* APDU has no body. This call is equivalent to
* <code>getData().length</code>.
*
* @return the number of data bytes in the response body or 0 if this APDU
* has no body.
*/
public int getNr() {
return apdu.length - 2;
}
/** {@collect.stats}
* Returns a copy of the data bytes in the response body. If this APDU as
* no body, this method returns a byte array with a length of zero.
*
* @return a copy of the data bytes in the response body or the empty
* byte array if this APDU has no body.
*/
public byte[] getData() {
byte[] data = new byte[apdu.length - 2];
System.arraycopy(apdu, 0, data, 0, data.length);
return data;
}
/** {@collect.stats}
* Returns the value of the status byte SW1 as a value between 0 and 255.
*
* @return the value of the status byte SW1 as a value between 0 and 255.
*/
public int getSW1() {
return apdu[apdu.length - 2] & 0xff;
}
/** {@collect.stats}
* Returns the value of the status byte SW2 as a value between 0 and 255.
*
* @return the value of the status byte SW2 as a value between 0 and 255.
*/
public int getSW2() {
return apdu[apdu.length - 1] & 0xff;
}
/** {@collect.stats}
* Returns the value of the status bytes SW1 and SW2 as a single
* status word SW.
* It is defined as
* <code>(getSW1() << 8) | getSW2()</code>.
*
* @return the value of the status word SW.
*/
public int getSW() {
return (getSW1() << 8) | getSW2();
}
/** {@collect.stats}
* Returns a copy of the bytes in this APDU.
*
* @return a copy of the bytes in this APDU.
*/
public byte[] getBytes() {
return apdu.clone();
}
/** {@collect.stats}
* Returns a string representation of this response APDU.
*
* @return a String representation of this response APDU.
*/
public String toString() {
return "ResponseAPDU: " + apdu.length + " bytes, SW="
+ Integer.toHexString(getSW());
}
/** {@collect.stats}
* Compares the specified object with this response APDU for equality.
* Returns true if the given object is also a ResponseAPDU and its bytes are
* identical to the bytes in this ResponseAPDU.
*
* @param obj the object to be compared for equality with this response APDU
* @return true if the specified object is equal to this response APDU
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ResponseAPDU == false) {
return false;
}
ResponseAPDU other = (ResponseAPDU)obj;
return Arrays.equals(this.apdu, other.apdu);
}
/** {@collect.stats}
* Returns the hash code value for this response APDU.
*
* @return the hash code value for this response APDU.
*/
public int hashCode() {
return Arrays.hashCode(apdu);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
apdu = (byte[])in.readUnshared();
check(apdu);
}
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
/** {@collect.stats}
* Exception thrown when an application tries to establish a connection with a
* terminal that has no card present.
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public class CardNotPresentException extends CardException {
private final static long serialVersionUID = 1346879911706545215L;
/** {@collect.stats}
* Constructs a new CardNotPresentException with the specified detail message.
*
* @param message the detail message
*/
public CardNotPresentException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new CardNotPresentException with the specified cause and a detail message
* of <code>(cause==null ? null : cause.toString())</code>.
*
* @param cause the cause of this exception or null
*/
public CardNotPresentException(Throwable cause) {
super(cause);
}
/** {@collect.stats}
* Constructs a new CardNotPresentException with the specified detail message and cause.
*
* @param message the detail message
* @param cause the cause of this exception or null
*/
public CardNotPresentException(String message, Throwable cause) {
super(message, cause);
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.nio.ByteBuffer;
/** {@collect.stats}
* A Smart Card with which a connection has been established. Card objects
* are obtained by calling {@link CardTerminal#connect CardTerminal.connect()}.
*
* @see CardTerminal
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public abstract class Card {
/** {@collect.stats}
* Constructs a new Card object.
*
* <p>This constructor is called by subclasses only. Application should
* call the {@linkplain CardTerminal#connect CardTerminal.connect()}
* method to obtain a Card
* object.
*/
protected Card() {
// empty
}
/** {@collect.stats}
* Returns the ATR of this card.
*
* @return the ATR of this card.
*/
public abstract ATR getATR();
/** {@collect.stats}
* Returns the protocol in use for this card.
*
* @return the protocol in use for this card, for example "T=0" or "T=1"
*/
public abstract String getProtocol();
/** {@collect.stats}
* Returns the CardChannel for the basic logical channel. The basic
* logical channel has a channel number of 0.
*
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
* @throws IllegalStateException if this card object has been disposed of
* via the {@linkplain #disconnect disconnect()} method
*/
public abstract CardChannel getBasicChannel();
/** {@collect.stats}
* Opens a new logical channel to the card and returns it. The channel is
* opened by issuing a <code>MANAGE CHANNEL</code> command that should use
* the format <code>[00 70 00 00 01]</code>.
*
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
* @throws CardException is a new logical channel could not be opened
* @throws IllegalStateException if this card object has been disposed of
* via the {@linkplain #disconnect disconnect()} method
*/
public abstract CardChannel openLogicalChannel() throws CardException;
/** {@collect.stats}
* Requests exclusive access to this card.
*
* <p>Once a thread has invoked <code>beginExclusive</code>, only this
* thread is allowed to communicate with this card until it calls
* <code>endExclusive</code>. Other threads attempting communication
* will receive a CardException.
*
* <p>Applications have to ensure that exclusive access is correctly
* released. This can be achieved by executing
* the <code>beginExclusive()</code> and <code>endExclusive</code> calls
* in a <code>try ... finally</code> block.
*
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
* @throws CardException if exclusive access has already been set
* or if exclusive access could not be established
* @throws IllegalStateException if this card object has been disposed of
* via the {@linkplain #disconnect disconnect()} method
*/
public abstract void beginExclusive() throws CardException;
/** {@collect.stats}
* Releases the exclusive access previously established using
* <code>beginExclusive</code>.
*
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
* @throws IllegalStateException if the active Thread does not currently have
* exclusive access to this card or
* if this card object has been disposed of
* via the {@linkplain #disconnect disconnect()} method
* @throws CardException if the operation failed
*/
public abstract void endExclusive() throws CardException;
/** {@collect.stats}
* Transmits a control command to the terminal device.
*
* <p>This can be used to, for example, control terminal functions like
* a built-in PIN pad or biometrics.
*
* @param controlCode the control code of the command
* @param command the command data
*
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
* @throws NullPointerException if command is null
* @throws CardException if the card operation failed
* @throws IllegalStateException if this card object has been disposed of
* via the {@linkplain #disconnect disconnect()} method
*/
public abstract byte[] transmitControlCommand(int controlCode,
byte[] command) throws CardException;
/** {@collect.stats}
* Disconnects the connection with this card. After this method returns,
* calling methods on this object or in CardChannels associated with this
* object that require interaction with the card will raise an
* IllegalStateException.
*
* @param reset whether to reset the card after disconnecting.
*
* @throws CardException if the card operation failed
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
*/
public abstract void disconnect(boolean reset) throws CardException;
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.*;
/** {@collect.stats}
* A Smart Card terminal, sometimes refered to as a Smart Card Reader.
* A CardTerminal object can be obtained by calling
* {@linkplain CardTerminals#list}
* or {@linkplain CardTerminals#getTerminal CardTerminals.getTerminal()}.
*
* <p>Note that physical card readers with slots for multiple cards are
* represented by one <code>CardTerminal</code> object per such slot.
*
* @see CardTerminals
* @see TerminalFactory
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public abstract class CardTerminal {
/** {@collect.stats}
* Constructs a new CardTerminal object.
*
* <p>This constructor is called by subclasses only. Application should
* call {@linkplain CardTerminals#list list()}
* or {@linkplain CardTerminals#getTerminal getTerminal()}
* to obtain a CardTerminal object.
*/
protected CardTerminal() {
// empty
}
/** {@collect.stats}
* Returns the unique name of this terminal.
*
* @return the unique name of this terminal.
*/
public abstract String getName();
/** {@collect.stats}
* Establishes a connection to the card.
* If a connection has previously established using
* the specified protocol, this method returns the same Card object as
* the previous call.
*
* @param protocol the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to
* connect using any available protocol.
*
* @throws NullPointerException if protocol is null
* @throws IllegalArgumentException if protocol is an invalid protocol
* specification
* @throws CardNotPresentException if no card is present in this terminal
* @throws CardException if a connection could not be established
* using the specified protocol or if a connection has previously been
* established using a different protocol
* @throws SecurityException if a SecurityManager exists and the
* caller does not have the required
* {@linkplain CardPermission permission}
*/
public abstract Card connect(String protocol) throws CardException;
/** {@collect.stats}
* Returns whether a card is present in this terminal.
*
* @return whether a card is present in this terminal.
*
* @throws CardException if the status could not be determined
*/
public abstract boolean isCardPresent() throws CardException;
/** {@collect.stats}
* Waits until a card is present in this terminal or the timeout
* expires. If the method returns due to an expired timeout, it returns
* false. Otherwise it return true.
*
* <P>If a card is present in this terminal when this
* method is called, it returns immediately.
*
* @param timeout if positive, block for up to <code>timeout</code>
* milliseconds; if zero, block indefinitely; must not be negative
* @return false if the method returns due to an expired timeout,
* true otherwise.
*
* @throws IllegalArgumentException if timeout is negative
* @throws CardException if the operation failed
*/
public abstract boolean waitForCardPresent(long timeout) throws CardException;
/** {@collect.stats}
* Waits until a card is absent in this terminal or the timeout
* expires. If the method returns due to an expired timeout, it returns
* false. Otherwise it return true.
*
* <P>If no card is present in this terminal when this
* method is called, it returns immediately.
*
* @param timeout if positive, block for up to <code>timeout</code>
* milliseconds; if zero, block indefinitely; must not be negative
* @return false if the method returns due to an expired timeout,
* true otherwise.
*
* @throws IllegalArgumentException if timeout is negative
* @throws CardException if the operation failed
*/
public abstract boolean waitForCardAbsent(long timeout) throws CardException;
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.*;
/** {@collect.stats}
* The TerminalFactorySpi class defines the service provider interface.
* Applications do not access this class directly, instead see
* {@linkplain TerminalFactory}.
*
* <P>Service providers that want to write a new implementation should define
* a concrete subclass of TerminalFactorySpi with a constructor that takes
* an <code>Object</code> as parameter. That class needs to be registered
* in a {@linkplain java.security.Provider}. The engine
* {@linkplain java.security.Provider.Service#getType type} is
* <code>TerminalFactory</code>.
* Service providers also need to implement subclasses of the abstract classes
* {@linkplain CardTerminals}, {@linkplain CardTerminal}, {@linkplain Card},
* and {@linkplain CardChannel}.
*
* <p>For example:
* <pre><em>file MyProvider.java:</em>
*
* package com.somedomain.card;
*
* import java.security.Provider;
*
* public class MyProvider extends Provider {
* public MyProvider() {
* super("MyProvider", 1.0d, "Smart Card Example");
* put("TerminalFactory.MyType", "com.somedomain.card.MySpi");
* }
* }
*
*<em>file MySpi.java</em>
*
* package com.somedomain.card;
*
* import javax.smartcardio.*;
*
* public class MySpi extends TerminalFactoySpi {
* public MySpi(Object parameter) {
* // initialize as appropriate
* }
* protected CardTerminals engineTerminals() {
* // add implementation code here
* }
* }
* </pre>
*
* @see TerminalFactory
* @see java.security.Provider
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public abstract class TerminalFactorySpi {
/** {@collect.stats}
* Constructs a new TerminalFactorySpi object.
*
* <p>This class is part of the service provider interface and not accessed
* directly by applications. Applications
* should use TerminalFactory objects, which can be obtained by calling
* one of the
* {@linkplain TerminalFactory#getInstance TerminalFactory.getInstance()}
* methods.
*
* <p>Concrete subclasses should define a constructor that takes an
* <code>Object</code> as parameter. It will be invoked when an
* application calls one of the {@linkplain TerminalFactory#getInstance
* TerminalFactory.getInstance()} methods and receives the <code>params</code>
* object specified by the application.
*/
protected TerminalFactorySpi() {
// empty
}
/** {@collect.stats}
* Returns the CardTerminals created by this factory.
*
* @return the CardTerminals created by this factory.
*/
protected abstract CardTerminals engineTerminals();
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.*;
import java.security.*;
import sun.security.jca.*;
import sun.security.jca.GetInstance.*;
import sun.security.action.GetPropertyAction;
/** {@collect.stats}
* A factory for CardTerminal objects.
*
* It allows an application to
* <ul>
* <li>obtain a TerminalFactory by calling
* one of the static factory methods in this class
* ({@linkplain #getDefault} or {@linkplain #getInstance getInstance()}).
* <li>use this TerminalFactory object to access the CardTerminals by
* calling the {@linkplain #terminals} method.
* </ul>
*
* <p>Each TerminalFactory has a <code>type</code> indicating how it
* was implemented. It must be specified when the implementation is obtained
* using a {@linkplain #getInstance getInstance()} method and can be retrieved
* via the {@linkplain #getType} method.
*
* <P>The following standard type names have been defined:
* <dl>
* <dt><code>PC/SC</code>
* <dd>an implementation that calls into the PC/SC Smart Card stack
* of the host platform.
* Implementations do not require parameters and accept "null" as argument
* in the getInstance() calls.
* <dt><code>None</code>
* <dd>an implementation that does not supply any CardTerminals. On platforms
* that do not support other implementations,
* {@linkplain #getDefaultType} returns <code>None</code> and
* {@linkplain #getDefault} returns an instance of a <code>None</code>
* TerminalFactory. Factories of this type cannot be obtained by calling the
* <code>getInstance()</code> methods.
* </dl>
* Additional standard types may be defined in the future.
*
* <p><strong>Note:</strong>
* Provider implementations that accept initialization parameters via the
* <code>getInstance()</code> methods are strongly
* encouraged to use a {@linkplain java.util.Properties} object as the
* representation for String name-value pair based parameters whenever
* possible. This allows applications to more easily interoperate with
* multiple providers than if each provider used different provider
* specific class as parameters.
*
* <P>TerminalFactory utilizes an extensible service provider framework.
* Service providers that wish to add a new implementation should see the
* {@linkplain TerminalFactorySpi} class for more information.
*
* @see CardTerminals
* @see Provider
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public final class TerminalFactory {
private final static String PROP_NAME =
"javax.smartcardio.TerminalFactory.DefaultType";
private final static String defaultType;
private final static TerminalFactory defaultFactory;
static {
// lookup up the user specified type, default to PC/SC
String type = AccessController.doPrivileged
(new GetPropertyAction(PROP_NAME, "PC/SC")).trim();
TerminalFactory factory = null;
try {
factory = TerminalFactory.getInstance(type, null);
} catch (Exception e) {
// ignore
}
if (factory == null) {
// if that did not work, try the Sun PC/SC factory
try {
type = "PC/SC";
Provider sun = Security.getProvider("SunPCSC");
if (sun == null) {
Class clazz = Class.forName("sun.security.smartcardio.SunPCSC");
sun = (Provider)clazz.newInstance();
}
factory = TerminalFactory.getInstance(type, null, sun);
} catch (Exception e) {
// ignore
}
}
if (factory == null) {
type = "None";
factory = new TerminalFactory
(NoneFactorySpi.INSTANCE, NoneProvider.INSTANCE, "None");
}
defaultType = type;
defaultFactory = factory;
}
private static final class NoneProvider extends Provider {
final static Provider INSTANCE = new NoneProvider();
private NoneProvider() {
super("None", 1.0d, "none");
}
}
private static final class NoneFactorySpi extends TerminalFactorySpi {
final static TerminalFactorySpi INSTANCE = new NoneFactorySpi();
private NoneFactorySpi() {
// empty
}
protected CardTerminals engineTerminals() {
return NoneCardTerminals.INSTANCE;
}
}
private static final class NoneCardTerminals extends CardTerminals {
final static CardTerminals INSTANCE = new NoneCardTerminals();
private NoneCardTerminals() {
// empty
}
public List<CardTerminal> list(State state) throws CardException {
if (state == null) {
throw new NullPointerException();
}
return Collections.emptyList();
}
public boolean waitForChange(long timeout) throws CardException {
throw new IllegalStateException("no terminals");
}
}
private final TerminalFactorySpi spi;
private final Provider provider;
private final String type;
private TerminalFactory(TerminalFactorySpi spi, Provider provider, String type) {
this.spi = spi;
this.provider = provider;
this.type = type;
}
/** {@collect.stats}
* Get the default TerminalFactory type.
*
* <p>It is determined as follows:
*
* when this class is initialized, the system property
* <code>javax.smartcardio.TerminalFactory.DefaultType</code>
* is examined. If it is set, a TerminalFactory of this type is
* instantiated by calling the {@linkplain #getInstance
* getInstance(String,Object)} method passing
* <code>null</code> as the value for <code>params</code>. If the call
* succeeds, the type becomes the default type and the factory becomes
* the {@linkplain #getDefault default} factory.
*
* <p>If the system property is not set or the getInstance() call fails
* for any reason, the system defaults to an implementation specific
* default type and TerminalFactory.
*
* @return the default TerminalFactory type
*/
public static String getDefaultType() {
return defaultType;
}
/** {@collect.stats}
* Returns the default TerminalFactory instance. See
* {@linkplain #getDefaultType} for more information.
*
* <p>A default TerminalFactory is always available. However, depending
* on the implementation, it may not offer any terminals.
*
* @return the default TerminalFactory
*/
public static TerminalFactory getDefault() {
return defaultFactory;
}
/** {@collect.stats}
* Returns a TerminalFactory of the specified type that is initialized
* with the specified parameters.
*
* <p> This method traverses the list of registered security Providers,
* starting with the most preferred Provider.
* A new TerminalFactory object encapsulating the
* TerminalFactorySpi implementation from the first
* Provider that supports the specified type is returned.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@linkplain Security#getProviders() Security.getProviders()} method.
*
* <p>The <code>TerminalFactory</code> is initialized with the
* specified parameters Object. The type of parameters
* needed may vary between different types of <code>TerminalFactory</code>s.
*
* @param type the type of the requested TerminalFactory
* @param params the parameters to pass to the TerminalFactorySpi
* implementation, or null if no parameters are needed
* @return a TerminalFactory of the specified type
*
* @throws NullPointerException if type is null
* @throws NoSuchAlgorithmException if no Provider supports a
* TerminalFactorySpi of the specified type
*/
public static TerminalFactory getInstance(String type, Object params)
throws NoSuchAlgorithmException {
Instance instance = GetInstance.getInstance("TerminalFactory",
TerminalFactorySpi.class, type, params);
return new TerminalFactory((TerminalFactorySpi)instance.impl,
instance.provider, type);
}
/** {@collect.stats}
* Returns a TerminalFactory of the specified type that is initialized
* with the specified parameters.
*
* <p> A new TerminalFactory object encapsulating the
* TerminalFactorySpi implementation from the specified provider
* is returned. The specified provider must be registered
* in the security provider list.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@linkplain Security#getProviders() Security.getProviders()} method.
*
* <p>The <code>TerminalFactory</code> is initialized with the
* specified parameters Object. The type of parameters
* needed may vary between different types of <code>TerminalFactory</code>s.
*
* @param type the type of the requested TerminalFactory
* @param params the parameters to pass to the TerminalFactorySpi
* implementation, or null if no parameters are needed
* @param provider the name of the provider
* @return a TerminalFactory of the specified type
*
* @throws NullPointerException if type is null
* @throws IllegalArgumentException if provider is null or the empty String
* @throws NoSuchAlgorithmException if a TerminalFactorySpi implementation
* of the specified type is not available from the specified provider
* @throws NoSuchAlgorithmException if no TerminalFactory of the
* specified type could be found
* @throws NoSuchProviderException if the specified provider could not
* be found
*/
public static TerminalFactory getInstance(String type, Object params,
String provider) throws NoSuchAlgorithmException, NoSuchProviderException {
Instance instance = GetInstance.getInstance("TerminalFactory",
TerminalFactorySpi.class, type, params, provider);
return new TerminalFactory((TerminalFactorySpi)instance.impl,
instance.provider, type);
}
/** {@collect.stats}
* Returns a TerminalFactory of the specified type that is initialized
* with the specified parameters.
*
* <p> A new TerminalFactory object encapsulating the
* TerminalFactorySpi implementation from the specified provider object
* is returned. Note that the specified provider object does not have to be
* registered in the provider list.
*
* <p>The <code>TerminalFactory</code> is initialized with the
* specified parameters Object. The type of parameters
* needed may vary between different types of <code>TerminalFactory</code>s.
*
* @param type the type of the requested TerminalFactory
* @param params the parameters to pass to the TerminalFactorySpi
* implementation, or null if no parameters are needed
* @param provider the provider
* @return a TerminalFactory of the specified type
*
* @throws NullPointerException if type is null
* @throws IllegalArgumentException if provider is null
* @throws NoSuchAlgorithmException if a TerminalFactorySpi implementation
* of the specified type is not available from the specified Provider
*/
public static TerminalFactory getInstance(String type, Object params,
Provider provider) throws NoSuchAlgorithmException {
Instance instance = GetInstance.getInstance("TerminalFactory",
TerminalFactorySpi.class, type, params, provider);
return new TerminalFactory((TerminalFactorySpi)instance.impl,
instance.provider, type);
}
/** {@collect.stats}
* Returns the provider of this TerminalFactory.
*
* @return the provider of this TerminalFactory.
*/
public Provider getProvider() {
return provider;
}
/** {@collect.stats}
* Returns the type of this TerminalFactory. This is the value that was
* specified in the getInstance() method that returned this object.
*
* @return the type of this TerminalFactory
*/
public String getType() {
return type;
}
/** {@collect.stats}
* Returns a new CardTerminals object encapsulating the terminals
* supported by this factory.
* See the class comment of the {@linkplain CardTerminals} class
* regarding how the returned objects can be shared and reused.
*
* @return a new CardTerminals object encapsulating the terminals
* supported by this factory.
*/
public CardTerminals terminals() {
return spi.engineTerminals();
}
/** {@collect.stats}
* Returns a string representation of this TerminalFactory.
*
* @return a string representation of this TerminalFactory.
*/
public String toString() {
return "TerminalFactory for type " + type + " from provider "
+ provider.getName();
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.io.*;
import java.security.Permission;
/** {@collect.stats}
* A permission for Smart Card operations. A CardPermission consists of the
* name of the card terminal the permission applies to and a set of actions
* that are valid for that terminal.
*
* <p>A CardPermission with a name of <code>*</code> applies to all
* card terminals. The actions string is a comma separated list of the actions
* listed below, or <code>*</code> to signify "all actions."
*
* <p>Individual actions are:
* <dl>
* <dt>connect
* <dd>connect to a card using
* {@linkplain CardTerminal#connect CardTerminal.connect()}
*
* <dt>reset
* <dd>reset the card using {@linkplain Card#disconnect Card.disconnect(true)}
*
* <dt>exclusive
* <dd>establish exclusive access to a card using
* {@linkplain Card#beginExclusive} and {@linkplain Card#endExclusive
* endExclusive()}
*
* <dt>transmitControl
* <dd>transmit a control command using
* {@linkplain Card#transmitControlCommand Card.transmitControlCommand()}
*
* <dt>getBasicChannel
* <dd>obtain the basic logical channel using
* {@linkplain Card#getBasicChannel}
*
* <dt>openLogicalChannel
* <dd>open a new logical channel using
* {@linkplain Card#openLogicalChannel}
*
* </dl>
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public class CardPermission extends Permission {
private static final long serialVersionUID = 7146787880530705613L;
private final static int A_CONNECT = 0x01;
private final static int A_EXCLUSIVE = 0x02;
private final static int A_GET_BASIC_CHANNEL = 0x04;
private final static int A_OPEN_LOGICAL_CHANNEL = 0x08;
private final static int A_RESET = 0x10;
private final static int A_TRANSMIT_CONTROL = 0x20;
// sum of all the actions above
private final static int A_ALL = 0x3f;
private final static int[] ARRAY_MASKS = {
A_ALL,
A_CONNECT,
A_EXCLUSIVE,
A_GET_BASIC_CHANNEL,
A_OPEN_LOGICAL_CHANNEL,
A_RESET,
A_TRANSMIT_CONTROL,
};
private final static String S_CONNECT = "connect";
private final static String S_EXCLUSIVE = "exclusive";
private final static String S_GET_BASIC_CHANNEL = "getBasicChannel";
private final static String S_OPEN_LOGICAL_CHANNEL = "openLogicalChannel";
private final static String S_RESET = "reset";
private final static String S_TRANSMIT_CONTROL = "transmitControl";
private final static String S_ALL = "*";
private final static String[] ARRAY_STRINGS = {
S_ALL,
S_CONNECT,
S_EXCLUSIVE,
S_GET_BASIC_CHANNEL,
S_OPEN_LOGICAL_CHANNEL,
S_RESET,
S_TRANSMIT_CONTROL,
};
private transient int mask;
/** {@collect.stats}
* @serial
*/
private volatile String actions;
/** {@collect.stats}
* Constructs a new CardPermission with the specified actions.
* <code>terminalName</code> is the name of a CardTerminal or <code>*</code>
* if this permission applies to all terminals. <code>actions</code>
* contains a comma-separated list of the individual actions
* or <code>*</code> to signify all actions. For more information,
* see the documentation at the top of this {@linkplain CardPermission
* class}.
*
* @param terminalName the name of the card terminal, or <code>*</code>
* @param actions the action string (or null if the set of permitted
* actions is empty)
*
* @throws NullPointerException if terminalName is null
* @throws IllegalArgumentException if actions is an invalid actions
* specification
*/
public CardPermission(String terminalName, String actions) {
super(terminalName);
if (terminalName == null) {
throw new NullPointerException();
}
mask = getMask(actions);
}
private static int getMask(String actions) {
if ((actions == null) || (actions.length() == 0)) {
throw new IllegalArgumentException("actions must not be empty");
}
// try exact matches for simple actions first
for (int i = 0; i < ARRAY_STRINGS.length; i++) {
if (actions == ARRAY_STRINGS[i]) {
return ARRAY_MASKS[i];
}
}
if (actions.endsWith(",")) {
throw new IllegalArgumentException("Invalid actions: '" + actions + "'");
}
int mask = 0;
String[] split = actions.split(",");
outer:
for (String s : split) {
for (int i = 0; i < ARRAY_STRINGS.length; i++) {
if (ARRAY_STRINGS[i].equalsIgnoreCase(s)) {
mask |= ARRAY_MASKS[i];
continue outer;
}
}
throw new IllegalArgumentException("Invalid action: '" + s + "'");
}
return mask;
}
private static String getActions(int mask) {
if (mask == A_ALL) {
return S_ALL;
}
boolean first = true;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ARRAY_MASKS.length; i++) {
int action = ARRAY_MASKS[i];
if ((mask & action) == action) {
if (first == false) {
sb.append(",");
} else {
first = false;
}
sb.append(ARRAY_STRINGS[i]);
}
}
return sb.toString();
}
/** {@collect.stats}
* Returns the canonical string representation of the actions.
* It is <code>*</code> to signify all actions defined by this class or
* the string concatenation of the comma-separated,
* lexicographically sorted list of individual actions.
*
* @return the canonical string representation of the actions.
*/
public String getActions() {
if (actions == null) {
actions = getActions(mask);
}
return actions;
}
/** {@collect.stats}
* Checks if this CardPermission object implies the specified permission.
* That is the case, if and only if
* <ul>
* <li><p><code>permission</code> is an instance of CardPermission,</p>
* <li><p><code>permission</code>'s actions are a proper subset of this
* object's actions, and</p>
* <li><p>this object's <code>getName()</code> method is either
* <code>*</code> or equal to <code>permission</code>'s <code>name</code>.
* </p>
* </ul>
*
* @param permission the permission to check against
* @return true if and only if this CardPermission object implies the
* specified permission.
*/
public boolean implies(Permission permission) {
if (permission instanceof CardPermission == false) {
return false;
}
CardPermission other = (CardPermission)permission;
if ((this.mask & other.mask) != other.mask) {
return false;
}
String thisName = getName();
if (thisName.equals("*")) {
return true;
}
if (thisName.equals(other.getName())) {
return true;
}
return false;
}
/** {@collect.stats}
* Compares the specified object with this CardPermission for equality.
* This CardPermission is equal to another Object <code>object</code>, if
* and only if
* <ul>
* <li><p><code>object</code> is an instance of CardPermission,</p>
* <li><p><code>this.getName()</code> is equal to
* <code>((CardPermission)object).getName()</code>, and</p>
* <li><p><code>this.getActions()</code> is equal to
* <code>((CardPermission)object).getActions()</code>.</p>
* </ul>
*
* @param obj the object to be compared for equality with this CardPermission
* @return true if and only if the specified object is equal to this
* CardPermission
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof CardPermission == false) {
return false;
}
CardPermission other = (CardPermission)obj;
return this.getName().equals(other.getName()) && (this.mask == other.mask);
}
/** {@collect.stats}
* Returns the hash code value for this CardPermission object.
*
* @return the hash code value for this CardPermission object.
*/
public int hashCode() {
return getName().hashCode() + 31 * mask;
}
private void writeObject(ObjectOutputStream s) throws IOException {
// Write out the actions. The superclass takes care of the name.
// Call getActions to make sure actions field is initialized
if (actions == null) {
getActions();
}
s.defaultWriteObject();
}
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
// Read in the actions, then restore the mask.
s.defaultReadObject();
mask = getMask(actions);
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.Arrays;
import java.nio.ByteBuffer;
/** {@collect.stats}
* A command APDU following the structure defined in ISO/IEC 7816-4.
* It consists of a four byte header and a conditional body of variable length.
* This class does not attempt to verify that the APDU encodes a semantically
* valid command.
*
* <p>Note that when the expected length of the response APDU is specified
* in the {@linkplain #CommandAPDU(int,int,int,int,int) constructors},
* the actual length (Ne) must be specified, not its
* encoded form (Le). Similarly, {@linkplain #getNe} returns the actual
* value Ne. In other words, a value of 0 means "no data in the response APDU"
* rather than "maximum length."
*
* <p>This class supports both the short and extended forms of length
* encoding for Ne and Nc. However, note that not all terminals and Smart Cards
* are capable of accepting APDUs that use the extended form.
*
* <p>For the header bytes CLA, INS, P1, and P2 the Java type <code>int</code>
* is used to represent the 8 bit unsigned values. In the constructors, only
* the 8 lowest bits of the <code>int</code> value specified by the application
* are significant. The accessor methods always return the byte as an unsigned
* value between 0 and 255.
*
* <p>Instances of this class are immutable. Where data is passed in or out
* via byte arrays, defensive cloning is performed.
*
* @see ResponseAPDU
* @see CardChannel#transmit CardChannel.transmit
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public final class CommandAPDU implements java.io.Serializable {
private static final long serialVersionUID = 398698301286670877L;
private static final int MAX_APDU_SIZE = 65544;
/** {@collect.stats} @serial */
private byte[] apdu;
// value of nc
private transient int nc;
// value of ne
private transient int ne;
// index of start of data within the apdu array
private transient int dataOffset;
/** {@collect.stats}
* Constructs a CommandAPDU from a byte array containing the complete
* APDU contents (header and body).
*
* <p>Note that the apdu bytes are copied to protect against
* subsequent modification.
*
* @param apdu the complete command APDU
*
* @throws NullPointerException if apdu is null
* @throws IllegalArgumentException if apdu does not contain a valid
* command APDU
*/
public CommandAPDU(byte[] apdu) {
this.apdu = apdu.clone();
parse();
}
/** {@collect.stats}
* Constructs a CommandAPDU from a byte array containing the complete
* APDU contents (header and body). The APDU starts at the index
* <code>apduOffset</code> in the byte array and is <code>apduLength</code>
* bytes long.
*
* <p>Note that the apdu bytes are copied to protect against
* subsequent modification.
*
* @param apdu the complete command APDU
* @param apduOffset the offset in the byte array at which the apdu
* data begins
* @param apduLength the length of the APDU
*
* @throws NullPointerException if apdu is null
* @throws IllegalArgumentException if apduOffset or apduLength are
* negative or if apduOffset + apduLength are greater than apdu.length,
* or if the specified bytes are not a valid APDU
*/
public CommandAPDU(byte[] apdu, int apduOffset, int apduLength) {
checkArrayBounds(apdu, apduOffset, apduLength);
this.apdu = new byte[apduLength];
System.arraycopy(apdu, apduOffset, this.apdu, 0, apduLength);
parse();
}
private void checkArrayBounds(byte[] b, int ofs, int len) {
if ((ofs < 0) || (len < 0)) {
throw new IllegalArgumentException
("Offset and length must not be negative");
}
if (b == null) {
if ((ofs != 0) && (len != 0)) {
throw new IllegalArgumentException
("offset and length must be 0 if array is null");
}
} else {
if (ofs > b.length - len) {
throw new IllegalArgumentException
("Offset plus length exceed array size");
}
}
}
/** {@collect.stats}
* Creates a CommandAPDU from the ByteBuffer containing the complete APDU
* contents (header and body).
* The buffer's <code>position</code> must be set to the start of the APDU,
* its <code>limit</code> to the end of the APDU. Upon return, the buffer's
* <code>position</code> is equal to its limit; its limit remains unchanged.
*
* <p>Note that the data in the ByteBuffer is copied to protect against
* subsequent modification.
*
* @param apdu the ByteBuffer containing the complete APDU
*
* @throws NullPointerException if apdu is null
* @throws IllegalArgumentException if apdu does not contain a valid
* command APDU
*/
public CommandAPDU(ByteBuffer apdu) {
this.apdu = new byte[apdu.remaining()];
apdu.get(this.apdu);
parse();
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes. This is case 1
* in ISO 7816, no command body.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
*/
public CommandAPDU(int cla, int ins, int p1, int p2) {
this(cla, ins, p1, p2, null, 0, 0, 0);
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes and the expected
* response data length. This is case 2 in ISO 7816, empty command data
* field with Ne specified. If Ne is 0, the APDU is encoded as ISO 7816
* case 1.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
* @param ne the maximum number of expected data bytes in a response APDU
*
* @throws IllegalArgumentException if ne is negative or greater than
* 65536
*/
public CommandAPDU(int cla, int ins, int p1, int p2, int ne) {
this(cla, ins, p1, p2, null, 0, 0, ne);
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes and command data.
* This is case 3 in ISO 7816, command data present and Ne absent. The
* value Nc is taken as data.length. If <code>data</code> is null or
* its length is 0, the APDU is encoded as ISO 7816 case 1.
*
* <p>Note that the data bytes are copied to protect against
* subsequent modification.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
* @param data the byte array containing the data bytes of the command body
*
* @throws IllegalArgumentException if data.length is greater than 65535
*/
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data) {
this(cla, ins, p1, p2, data, 0, arrayLength(data), 0);
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes and command data.
* This is case 3 in ISO 7816, command data present and Ne absent. The
* value Nc is taken as dataLength. If <code>dataLength</code>
* is 0, the APDU is encoded as ISO 7816 case 1.
*
* <p>Note that the data bytes are copied to protect against
* subsequent modification.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
* @param data the byte array containing the data bytes of the command body
* @param dataOffset the offset in the byte array at which the data
* bytes of the command body begin
* @param dataLength the number of the data bytes in the command body
*
* @throws NullPointerException if data is null and dataLength is not 0
* @throws IllegalArgumentException if dataOffset or dataLength are
* negative or if dataOffset + dataLength are greater than data.length
* or if dataLength is greater than 65535
*/
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data,
int dataOffset, int dataLength) {
this(cla, ins, p1, p2, data, dataOffset, dataLength, 0);
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes, command data,
* and expected response data length. This is case 4 in ISO 7816,
* command data and Ne present. The value Nc is taken as data.length
* if <code>data</code> is non-null and as 0 otherwise. If Ne or Nc
* are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.
*
* <p>Note that the data bytes are copied to protect against
* subsequent modification.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
* @param data the byte array containing the data bytes of the command body
* @param ne the maximum number of expected data bytes in a response APDU
*
* @throws IllegalArgumentException if data.length is greater than 65535
* or if ne is negative or greater than 65536
*/
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data, int ne) {
this(cla, ins, p1, p2, data, 0, arrayLength(data), ne);
}
private static int arrayLength(byte[] b) {
return (b != null) ? b.length : 0;
}
/** {@collect.stats}
* Command APDU encoding options:
*
* case 1: |CLA|INS|P1 |P2 | len = 4
* case 2s: |CLA|INS|P1 |P2 |LE | len = 5
* case 3s: |CLA|INS|P1 |P2 |LC |...BODY...| len = 6..260
* case 4s: |CLA|INS|P1 |P2 |LC |...BODY...|LE | len = 7..261
* case 2e: |CLA|INS|P1 |P2 |00 |LE1|LE2| len = 7
* case 3e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...| len = 8..65542
* case 4e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...|LE1|LE2| len =10..65544
*
* LE, LE1, LE2 may be 0x00.
* LC must not be 0x00 and LC1|LC2 must not be 0x00|0x00
*/
private void parse() {
if (apdu.length < 4) {
throw new IllegalArgumentException("apdu must be at least 4 bytes long");
}
if (apdu.length == 4) {
// case 1
return;
}
int l1 = apdu[4] & 0xff;
if (apdu.length == 5) {
// case 2s
this.ne = (l1 == 0) ? 256 : l1;
return;
}
if (l1 != 0) {
if (apdu.length == 4 + 1 + l1) {
// case 3s
this.nc = l1;
this.dataOffset = 5;
return;
} else if (apdu.length == 4 + 2 + l1) {
// case 4s
this.nc = l1;
this.dataOffset = 5;
int l2 = apdu[apdu.length - 1] & 0xff;
this.ne = (l2 == 0) ? 256 : l2;
return;
} else {
throw new IllegalArgumentException
("Invalid APDU: length=" + apdu.length + ", b1=" + l1);
}
}
if (apdu.length < 7) {
throw new IllegalArgumentException
("Invalid APDU: length=" + apdu.length + ", b1=" + l1);
}
int l2 = ((apdu[5] & 0xff) << 8) | (apdu[6] & 0xff);
if (apdu.length == 7) {
// case 2e
this.ne = (l2 == 0) ? 65536 : l2;
return;
}
if (l2 == 0) {
throw new IllegalArgumentException("Invalid APDU: length="
+ apdu.length + ", b1=" + l1 + ", b2||b3=" + l2);
}
if (apdu.length == 4 + 3 + l2) {
// case 3e
this.nc = l2;
this.dataOffset = 7;
return;
} else if (apdu.length == 4 + 5 + l2) {
// case 4e
this.nc = l2;
this.dataOffset = 7;
int leOfs = apdu.length - 2;
int l3 = ((apdu[leOfs] & 0xff) << 8) | (apdu[leOfs + 1] & 0xff);
this.ne = (l3 == 0) ? 65536 : l3;
} else {
throw new IllegalArgumentException("Invalid APDU: length="
+ apdu.length + ", b1=" + l1 + ", b2||b3=" + l2);
}
}
/** {@collect.stats}
* Constructs a CommandAPDU from the four header bytes, command data,
* and expected response data length. This is case 4 in ISO 7816,
* command data and Le present. The value Nc is taken as
* <code>dataLength</code>.
* If Ne or Nc
* are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.
*
* <p>Note that the data bytes are copied to protect against
* subsequent modification.
*
* @param cla the class byte CLA
* @param ins the instruction byte INS
* @param p1 the parameter byte P1
* @param p2 the parameter byte P2
* @param data the byte array containing the data bytes of the command body
* @param dataOffset the offset in the byte array at which the data
* bytes of the command body begin
* @param dataLength the number of the data bytes in the command body
* @param ne the maximum number of expected data bytes in a response APDU
*
* @throws NullPointerException if data is null and dataLength is not 0
* @throws IllegalArgumentException if dataOffset or dataLength are
* negative or if dataOffset + dataLength are greater than data.length,
* or if ne is negative or greater than 65536,
* or if dataLength is greater than 65535
*/
public CommandAPDU(int cla, int ins, int p1, int p2, byte[] data,
int dataOffset, int dataLength, int ne) {
checkArrayBounds(data, dataOffset, dataLength);
if (dataLength > 65535) {
throw new IllegalArgumentException("dataLength is too large");
}
if (ne < 0) {
throw new IllegalArgumentException("ne must not be negative");
}
if (ne > 65536) {
throw new IllegalArgumentException("ne is too large");
}
this.ne = ne;
this.nc = dataLength;
if (dataLength == 0) {
if (ne == 0) {
// case 1
this.apdu = new byte[4];
setHeader(cla, ins, p1, p2);
} else {
// case 2s or 2e
if (ne <= 256) {
// case 2s
// 256 is encoded as 0x00
byte len = (ne != 256) ? (byte)ne : 0;
this.apdu = new byte[5];
setHeader(cla, ins, p1, p2);
this.apdu[4] = len;
} else {
// case 2e
byte l1, l2;
// 65536 is encoded as 0x00 0x00
if (ne == 65536) {
l1 = 0;
l2 = 0;
} else {
l1 = (byte)(ne >> 8);
l2 = (byte)ne;
}
this.apdu = new byte[7];
setHeader(cla, ins, p1, p2);
this.apdu[5] = l1;
this.apdu[6] = l2;
}
}
} else {
if (ne == 0) {
// case 3s or 3e
if (dataLength <= 255) {
// case 3s
apdu = new byte[4 + 1 + dataLength];
setHeader(cla, ins, p1, p2);
apdu[4] = (byte)dataLength;
this.dataOffset = 5;
System.arraycopy(data, dataOffset, apdu, 5, dataLength);
} else {
// case 3e
apdu = new byte[4 + 3 + dataLength];
setHeader(cla, ins, p1, p2);
apdu[4] = 0;
apdu[5] = (byte)(dataLength >> 8);
apdu[6] = (byte)dataLength;
this.dataOffset = 7;
System.arraycopy(data, dataOffset, apdu, 7, dataLength);
}
} else {
// case 4s or 4e
if ((dataLength <= 255) && (ne <= 256)) {
// case 4s
apdu = new byte[4 + 2 + dataLength];
setHeader(cla, ins, p1, p2);
apdu[4] = (byte)dataLength;
this.dataOffset = 5;
System.arraycopy(data, dataOffset, apdu, 5, dataLength);
apdu[apdu.length - 1] = (ne != 256) ? (byte)ne : 0;
} else {
// case 4e
apdu = new byte[4 + 5 + dataLength];
setHeader(cla, ins, p1, p2);
apdu[4] = 0;
apdu[5] = (byte)(dataLength >> 8);
apdu[6] = (byte)dataLength;
this.dataOffset = 7;
System.arraycopy(data, dataOffset, apdu, 7, dataLength);
if (ne != 65536) {
int leOfs = apdu.length - 2;
apdu[leOfs] = (byte)(ne >> 8);
apdu[leOfs + 1] = (byte)ne;
} // else le == 65536: no need to fill in, encoded as 0
}
}
}
}
private void setHeader(int cla, int ins, int p1, int p2) {
apdu[0] = (byte)cla;
apdu[1] = (byte)ins;
apdu[2] = (byte)p1;
apdu[3] = (byte)p2;
}
/** {@collect.stats}
* Returns the value of the class byte CLA.
*
* @return the value of the class byte CLA.
*/
public int getCLA() {
return apdu[0] & 0xff;
}
/** {@collect.stats}
* Returns the value of the instruction byte INS.
*
* @return the value of the instruction byte INS.
*/
public int getINS() {
return apdu[1] & 0xff;
}
/** {@collect.stats}
* Returns the value of the parameter byte P1.
*
* @return the value of the parameter byte P1.
*/
public int getP1() {
return apdu[2] & 0xff;
}
/** {@collect.stats}
* Returns the value of the parameter byte P2.
*
* @return the value of the parameter byte P2.
*/
public int getP2() {
return apdu[3] & 0xff;
}
/** {@collect.stats}
* Returns the number of data bytes in the command body (Nc) or 0 if this
* APDU has no body. This call is equivalent to
* <code>getData().length</code>.
*
* @return the number of data bytes in the command body or 0 if this APDU
* has no body.
*/
public int getNc() {
return nc;
}
/** {@collect.stats}
* Returns a copy of the data bytes in the command body. If this APDU as
* no body, this method returns a byte array with length zero.
*
* @return a copy of the data bytes in the command body or the empty
* byte array if this APDU has no body.
*/
public byte[] getData() {
byte[] data = new byte[nc];
System.arraycopy(apdu, dataOffset, data, 0, nc);
return data;
}
/** {@collect.stats}
* Returns the maximum number of expected data bytes in a response
* APDU (Ne).
*
* @return the maximum number of expected data bytes in a response APDU.
*/
public int getNe() {
return ne;
}
/** {@collect.stats}
* Returns a copy of the bytes in this APDU.
*
* @return a copy of the bytes in this APDU.
*/
public byte[] getBytes() {
return apdu.clone();
}
/** {@collect.stats}
* Returns a string representation of this command APDU.
*
* @return a String representation of this command APDU.
*/
public String toString() {
return "CommmandAPDU: " + apdu.length + " bytes, nc=" + nc + ", ne=" + ne;
}
/** {@collect.stats}
* Compares the specified object with this command APDU for equality.
* Returns true if the given object is also a CommandAPDU and its bytes are
* identical to the bytes in this CommandAPDU.
*
* @param obj the object to be compared for equality with this command APDU
* @return true if the specified object is equal to this command APDU
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof CommandAPDU == false) {
return false;
}
CommandAPDU other = (CommandAPDU)obj;
return Arrays.equals(this.apdu, other.apdu);
}
/** {@collect.stats}
* Returns the hash code value for this command APDU.
*
* @return the hash code value for this command APDU.
*/
public int hashCode() {
return Arrays.hashCode(apdu);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
apdu = (byte[])in.readUnshared();
// initialize transient fields
parse();
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.nio.*;
/** {@collect.stats}
* A logical channel connection to a Smart Card. It is used to exchange APDUs
* with a Smart Card.
* A CardChannel object can be obtained by calling the method
* {@linkplain Card#getBasicChannel} or {@linkplain Card#openLogicalChannel}.
*
* @see Card
* @see CommandAPDU
* @see ResponseAPDU
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public abstract class CardChannel {
/** {@collect.stats}
* Constructs a new CardChannel object.
*
* <p>This constructor is called by subclasses only. Application should
* call the {@linkplain Card#getBasicChannel} and
* {@linkplain Card#openLogicalChannel} methods to obtain a CardChannel
* object.
*/
protected CardChannel() {
// empty
}
/** {@collect.stats}
* Returns the Card this channel is associated with.
*
* @return the Card this channel is associated with
*/
public abstract Card getCard();
/** {@collect.stats}
* Returns the channel number of this CardChannel. A channel number of
* 0 indicates the basic logical channel.
*
* @return the channel number of this CardChannel.
*
* @throws IllegalStateException if this channel has been
* {@linkplain #close closed} or if the corresponding Card has been
* {@linkplain Card#disconnect disconnected}.
*/
public abstract int getChannelNumber();
/** {@collect.stats}
* Transmits the specified command APDU to the Smart Card and returns the
* response APDU.
*
* <p>The CLA byte of the command APDU is automatically adjusted to
* match the channel number of this CardChannel.
*
* <p>Note that this method cannot be used to transmit
* <code>MANAGE CHANNEL</code> APDUs. Logical channels should be managed
* using the {@linkplain Card#openLogicalChannel} and {@linkplain
* CardChannel#close CardChannel.close()} methods.
*
* <p>Implementations should transparently handle artifacts
* of the transmission protocol.
* For example, when using the T=0 protocol, the following processing
* should occur as described in ISO/IEC 7816-4:
*
* <ul>
* <li><p>if the response APDU has an SW1 of <code>61</code>, the
* implementation should issue a <code>GET RESPONSE</code> command
* using <code>SW2</code> as the <code>Le</code>field.
* This process is repeated as long as an SW1 of <code>61</code> is
* received. The response body of these exchanges is concatenated
* to form the final response body.
*
* <li><p>if the response APDU is <code>6C XX</code>, the implementation
* should reissue the command using <code>XX</code> as the
* <code>Le</code> field.
* </ul>
*
* <p>The ResponseAPDU returned by this method is the result
* after this processing has been performed.
*
* @param command the command APDU
* @return the response APDU received from the card
*
* @throws IllegalStateException if this channel has been
* {@linkplain #close closed} or if the corresponding Card has been
* {@linkplain Card#disconnect disconnected}.
* @throws IllegalArgumentException if the APDU encodes a
* <code>MANAGE CHANNEL</code> command
* @throws NullPointerException if command is null
* @throws CardException if the card operation failed
*/
public abstract ResponseAPDU transmit(CommandAPDU command) throws CardException;
/** {@collect.stats}
* Transmits the command APDU stored in the command ByteBuffer and receives
* the reponse APDU in the response ByteBuffer.
*
* <p>The command buffer must contain valid command APDU data starting
* at <code>command.position()</code> and the APDU must be
* <code>command.remaining()</code> bytes long.
* Upon return, the command buffer's position will be equal
* to its limit; its limit will not have changed. The output buffer
* will have received the response APDU bytes. Its position will have
* advanced by the number of bytes received, which is also the return
* value of this method.
*
* <p>The CLA byte of the command APDU is automatically adjusted to
* match the channel number of this CardChannel.
*
* <p>Note that this method cannot be used to transmit
* <code>MANAGE CHANNEL</code> APDUs. Logical channels should be managed
* using the {@linkplain Card#openLogicalChannel} and {@linkplain
* CardChannel#close CardChannel.close()} methods.
*
* <p>See {@linkplain #transmit transmit()} for a discussion of the handling
* of response APDUs with the SW1 values <code>61</code> or <code>6C</code>.
*
* @param command the buffer containing the command APDU
* @param response the buffer that shall receive the response APDU from
* the card
* @return the length of the received response APDU
*
* @throws IllegalStateException if this channel has been
* {@linkplain #close closed} or if the corresponding Card has been
* {@linkplain Card#disconnect disconnected}.
* @throws NullPointerException if command or response is null
* @throws ReadOnlyBufferException if the response buffer is read-only
* @throws IllegalArgumentException if command and response are the
* same object, if <code>response</code> may not have
* sufficient space to receive the response APDU
* or if the APDU encodes a <code>MANAGE CHANNEL</code> command
* @throws CardException if the card operation failed
*/
public abstract int transmit(ByteBuffer command, ByteBuffer response)
throws CardException;
/** {@collect.stats}
* Closes this CardChannel. The logical channel is closed by issuing
* a <code>MANAGE CHANNEL</code> command that should use the format
* <code>[xx 70 80 0n]</code> where <code>n</code> is the channel number
* of this channel and <code>xx</code> is the <code>CLA</code>
* byte that encodes this logical channel and has all other bits set to 0.
* After this method returns, calling other
* methods in this class will raise an IllegalStateException.
*
* <p>Note that the basic logical channel cannot be closed using this
* method. It can be closed by calling {@link Card#disconnect}.
*
* @throws CardException if the card operation failed
* @throws IllegalStateException if this CardChannel represents a
* connection the basic logical channel
*/
public abstract void close() throws CardException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
/** {@collect.stats}
* Exception for errors that occur during communication with the
* Smart Card stack or the card itself.
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public class CardException extends Exception {
private static final long serialVersionUID = 7787607144922050628L;
/** {@collect.stats}
* Constructs a new CardException with the specified detail message.
*
* @param message the detail message
*/
public CardException(String message) {
super(message);
}
/** {@collect.stats}
* Constructs a new CardException with the specified cause and a detail message
* of <code>(cause==null ? null : cause.toString())</code>.
*
* @param cause the cause of this exception or null
*/
public CardException(Throwable cause) {
super(cause);
}
/** {@collect.stats}
* Constructs a new CardException with the specified detail message and cause.
*
* @param message the detail message
* @param cause the cause of this exception or null
*/
public CardException(String message, Throwable cause) {
super(message, cause);
}
}
| Java |
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.*;
/** {@collect.stats}
* The set of terminals supported by a TerminalFactory.
* This class allows applications to enumerate the available CardTerminals,
* obtain a specific CardTerminal, or wait for the insertion or removal of
* cards.
*
* <p>This class is multi-threading safe and can be used by multiple
* threads concurrently. However, this object keeps track of the card
* presence state of each of its terminals. Multiple objects should be used
* if independent calls to {@linkplain #waitForChange} are required.
*
* <p>Applications can obtain instances of this class by calling
* {@linkplain TerminalFactory#terminals}.
*
* @see TerminalFactory
* @see CardTerminal
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public abstract class CardTerminals {
/** {@collect.stats}
* Constructs a new CardTerminals object.
*
* <p>This constructor is called by subclasses only. Application should
* call {@linkplain TerminalFactory#terminals}
* to obtain a CardTerminals object.
*/
protected CardTerminals() {
// empty
}
/** {@collect.stats}
* Returns an unmodifiable list of all available terminals.
*
* @return an unmodifiable list of all available terminals.
*
* @throws CardException if the card operation failed
*/
public List<CardTerminal> list() throws CardException {
return list(State.ALL);
}
/** {@collect.stats}
* Returns an unmodifiable list of all terminals matching the specified
* state.
*
* <p>If state is {@link State#ALL State.ALL}, this method returns
* all CardTerminals encapsulated by this object.
* If state is {@link State#CARD_PRESENT State.CARD_PRESENT} or
* {@link State#CARD_ABSENT State.CARD_ABSENT}, it returns all
* CardTerminals where a card is currently present or absent, respectively.
*
* <p>If state is {@link State#CARD_INSERTION State.CARD_INSERTION} or
* {@link State#CARD_REMOVAL State.CARD_REMOVAL}, it returns all
* CardTerminals for which an insertion (or removal, respectively)
* was detected during the last call to {@linkplain #waitForChange}.
* If <code>waitForChange()</code> has not been called on this object,
* <code>CARD_INSERTION</code> is equivalent to <code>CARD_PRESENT</code>
* and <code>CARD_REMOVAL</code> is equivalent to <code>CARD_ABSENT</code>.
* For an example of the use of <code>CARD_INSERTION</code>,
* see {@link #waitForChange}.
*
* @param state the State
* @return an unmodifiable list of all terminals matching the specified
* attribute.
*
* @throws NullPointerException if attr is null
* @throws CardException if the card operation failed
*/
public abstract List<CardTerminal> list(State state) throws CardException;
/** {@collect.stats}
* Returns the terminal with the specified name or null if no such
* terminal exists.
*
* @return the terminal with the specified name or null if no such
* terminal exists.
*
* @throws NullPointerException if name is null
*/
public CardTerminal getTerminal(String name) {
if (name == null) {
throw new NullPointerException();
}
try {
for (CardTerminal terminal : list()) {
if (terminal.getName().equals(name)) {
return terminal;
}
}
return null;
} catch (CardException e) {
return null;
}
}
/** {@collect.stats}
* Waits for card insertion or removal in any of the terminals of this
* object.
*
* <p>This call is equivalent to calling
* {@linkplain #waitForChange(long) waitForChange(0)}.
*
* @throws IllegalStateException if this <code>CardTerminals</code>
* object does not contain any terminals
* @throws CardException if the card operation failed
*/
public void waitForChange() throws CardException {
waitForChange(0);
}
/** {@collect.stats}
* Waits for card insertion or removal in any of the terminals of this
* object or until the timeout expires.
*
* <p>This method examines each CardTerminal of this object.
* If a card was inserted into or removed from a CardTerminal since the
* previous call to <code>waitForChange()</code>, it returns
* immediately.
* Otherwise, or if this is the first call to <code>waitForChange()</code>
* on this object, it blocks until a card is inserted into or removed from
* a CardTerminal.
*
* <p>If <code>timeout</code> is greater than 0, the method returns after
* <code>timeout</code> milliseconds even if there is no change in state.
* In that case, this method returns <code>false</code>; otherwise it
* returns <code>true</code>.
*
* <p>This method is often used in a loop in combination with
* {@link #list(CardTerminals.State) list(State.CARD_INSERTION)},
* for example:
* <pre>
* TerminalFactory factory = ...;
* CardTerminals terminals = factory.terminals();
* while (true) {
* for (CardTerminal terminal : terminals.list(CARD_INSERTION)) {
* // examine Card in terminal, return if it matches
* }
* terminals.waitForChange();
* }</pre>
*
* @param timeout if positive, block for up to <code>timeout</code>
* milliseconds; if zero, block indefinitely; must not be negative
* @return false if the method returns due to an expired timeout,
* true otherwise.
*
* @throws IllegalStateException if this <code>CardTerminals</code>
* object does not contain any terminals
* @throws IllegalArgumentException if timeout is negative
* @throws CardException if the card operation failed
*/
public abstract boolean waitForChange(long timeout) throws CardException;
/** {@collect.stats}
* Enumeration of attributes of a CardTerminal.
* It is used as a parameter to the {@linkplain CardTerminals#list} method.
*
* @since 1.6
*/
public static enum State {
/** {@collect.stats}
* All CardTerminals.
*/
ALL,
/** {@collect.stats}
* CardTerminals in which a card is present.
*/
CARD_PRESENT,
/** {@collect.stats}
* CardTerminals in which a card is not present.
*/
CARD_ABSENT,
/** {@collect.stats}
* CardTerminals for which a card insertion was detected during the
* latest call to {@linkplain State#waitForChange waitForChange()}
* call.
*/
CARD_INSERTION,
/** {@collect.stats}
* CardTerminals for which a card removal was detected during the
* latest call to {@linkplain State#waitForChange waitForChange()}
* call.
*/
CARD_REMOVAL,
}
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.smartcardio;
import java.util.*;
/** {@collect.stats}
* A Smart Card's answer-to-reset bytes. A Card's ATR object can be obtained
* by calling {@linkplain Card#getATR}.
* This class does not attempt to verify that the ATR encodes a semantically
* valid structure.
*
* <p>Instances of this class are immutable. Where data is passed in or out
* via byte arrays, defensive cloning is performed.
*
* @see Card#getATR
*
* @since 1.6
* @author Andreas Sterbenz
* @author JSR 268 Expert Group
*/
public final class ATR implements java.io.Serializable {
private static final long serialVersionUID = 6695383790847736493L;
private byte[] atr;
private transient int startHistorical, nHistorical;
/** {@collect.stats}
* Constructs an ATR from a byte array.
*
* @param atr the byte array containing the answer-to-reset bytes
* @throws NullPointerException if <code>atr</code> is null
*/
public ATR(byte[] atr) {
this.atr = atr.clone();
parse();
}
private void parse() {
if (atr.length < 2) {
return;
}
if ((atr[0] != 0x3b) && (atr[0] != 0x3f)) {
return;
}
int t0 = (atr[1] & 0xf0) >> 4;
int n = atr[1] & 0xf;
int i = 2;
while ((t0 != 0) && (i < atr.length)) {
if ((t0 & 1) != 0) {
i++;
}
if ((t0 & 2) != 0) {
i++;
}
if ((t0 & 4) != 0) {
i++;
}
if ((t0 & 8) != 0) {
if (i >= atr.length) {
return;
}
t0 = (atr[i++] & 0xf0) >> 4;
} else {
t0 = 0;
}
}
int k = i + n;
if ((k == atr.length) || (k == atr.length - 1)) {
startHistorical = i;
nHistorical = n;
}
}
/** {@collect.stats}
* Returns a copy of the bytes in this ATR.
*
* @return a copy of the bytes in this ATR.
*/
public byte[] getBytes() {
return atr.clone();
}
/** {@collect.stats}
* Returns a copy of the historical bytes in this ATR.
* If this ATR does not contain historical bytes, an array of length
* zero is returned.
*
* @return a copy of the historical bytes in this ATR.
*/
public byte[] getHistoricalBytes() {
byte[] b = new byte[nHistorical];
System.arraycopy(atr, startHistorical, b, 0, nHistorical);
return b;
}
/** {@collect.stats}
* Returns a string representation of this ATR.
*
* @return a String representation of this ATR.
*/
public String toString() {
return "ATR: " + atr.length + " bytes";
}
/** {@collect.stats}
* Compares the specified object with this ATR for equality.
* Returns true if the given object is also an ATR and its bytes are
* identical to the bytes in this ATR.
*
* @param obj the object to be compared for equality with this ATR
* @return true if the specified object is equal to this ATR
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ATR == false) {
return false;
}
ATR other = (ATR)obj;
return Arrays.equals(this.atr, other.atr);
}
/** {@collect.stats}
* Returns the hash code value for this ATR.
*
* @return the hash code value for this ATR.
*/
public int hashCode() {
return Arrays.hashCode(atr);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
atr = (byte[])in.readUnshared();
parse();
}
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.SQLException;
/** {@collect.stats}
* A factory for <code>PooledConnection</code>
* objects. An object that implements this interface will typically be
* registered with a naming service that is based on the
* Java<sup><font size=-2>TM</font></sup> Naming and Directory Interface
* (JNDI).
*
* @since 1.4
*/
public interface ConnectionPoolDataSource extends CommonDataSource {
/** {@collect.stats}
* Attempts to establish a physical database connection that can
* be used as a pooled connection.
*
* @return a <code>PooledConnection</code> object that is a physical
* connection to the database that this
* <code>ConnectionPoolDataSource</code> object represents
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
PooledConnection getPooledConnection() throws SQLException;
/** {@collect.stats}
* Attempts to establish a physical database connection that can
* be used as a pooled connection.
*
* @param user the database user on whose behalf the connection is being made
* @param password the user's password
* @return a <code>PooledConnection</code> object that is a physical
* connection to the database that this
* <code>ConnectionPoolDataSource</code> object represents
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
PooledConnection getPooledConnection(String user, String password)
throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
/** {@collect.stats}
* An object that provides support for distributed
* transactions. An <code>XAConnection</code> object may be enlisted
* in a distributed transaction by means of an <code>XAResource</code> object.
* A transaction manager, usually part of a middle tier server, manages an
* <code>XAConnection</code> object through the <code>XAResource</code> object.
* <P>
* An application programmer does not use this interface directly; rather,
* it is used by a transaction manager working in the middle tier server.
*
* @since 1.4
*/
public interface XAConnection extends PooledConnection {
/** {@collect.stats}
* Retrieves an <code>XAResource</code> object that
* the transaction manager will use
* to manage this <code>XAConnection</code> object's participation in a
* distributed transaction.
*
* @return the <code>XAResource</code> object
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
javax.transaction.xa.XAResource getXAResource() throws SQLException;
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Created on Apr 28, 2005
*/
package javax.sql;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.EventObject;
/** {@collect.stats}
* A <code>StatementEvent</code> is sent to all <code>StatementEventListener</code>s which were
* registered with a <code>PooledConnection</code>. This occurs when the driver determines that a
* <code>PreparedStatement</code> that is associated with the <code>PooledConnection</code> has been closed or the driver determines
* is invalid.
* <p>
* @since 1.6
*/
public class StatementEvent extends EventObject {
private SQLException exception;
private PreparedStatement statement;
/** {@collect.stats}
* Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code> and
* <code>PreparedStatement</code>. The <code>SQLException</code> contained in the event defaults to
* null.
* <p>
* @param con The <code>PooledConnection</code> that the closed or invalid
* <code>PreparedStatement</code>is associated with.
* @param statement The <code>PreparedStatement</code> that is bieng closed or is invalid
* <p>
* @throws IllegalArgumentException if <code>con</code> is null.
*
* @since 1.6
*/
public StatementEvent(PooledConnection con,
PreparedStatement statement) {
super(con);
this.statement = statement;
this.exception = null;
}
/** {@collect.stats}
* Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code>,
* <code>PreparedStatement</code> and <code>SQLException</code>
* <p>
* @param con The <code>PooledConnection</code> that the closed or invalid <code>PreparedStatement</code>
* is associated with.
* @param statement The <code>PreparedStatement</code> that is being closed or is invalid
* @param exception The <code>SQLException </code>the driver is about to throw to
* the application
*
* @throws IllegalArgumentException if <code>con</code> is null.
* <p>
* @since 1.6
*/
public StatementEvent(PooledConnection con,
PreparedStatement statement,
SQLException exception) {
super(con);
this.statement = statement;
this.exception = exception;
}
/** {@collect.stats}
* Returns the <code>PreparedStatement</code> that is being closed or is invalid
* <p>
* @return The <code>PreparedStatement</code> that is being closed or is invalid
* <p>
* @since 1.6
*/
public PreparedStatement getStatement() {
return this.statement;
}
/** {@collect.stats}
* Returns the <code>SQLException</code> the driver is about to throw
* <p>
* @return The <code>SQLException</code> the driver is about to throw
* <p>
* @since 1.6
*/
public SQLException getSQLException() {
return this.exception;
}
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Wrapper;
/** {@collect.stats}
* <p>A factory for connections to the physical data source that this
* <code>DataSource</code> object represents. An alternative to the
* <code>DriverManager</code> facility, a <code>DataSource</code> object
* is the preferred means of getting a connection. An object that implements
* the <code>DataSource</code> interface will typically be
* registered with a naming service based on the
* Java<sup><font size=-2>TM</font></sup> Naming and Directory (JNDI) API.
* <P>
* The <code>DataSource</code> interface is implemented by a driver vendor.
* There are three types of implementations:
* <OL>
* <LI>Basic implementation -- produces a standard <code>Connection</code>
* object
* <LI>Connection pooling implementation -- produces a <code>Connection</code>
* object that will automatically participate in connection pooling. This
* implementation works with a middle-tier connection pooling manager.
* <LI>Distributed transaction implementation -- produces a
* <code>Connection</code> object that may be used for distributed
* transactions and almost always participates in connection pooling.
* This implementation works with a middle-tier
* transaction manager and almost always with a connection
* pooling manager.
* </OL>
* <P>
* A <code>DataSource</code> object has properties that can be modified
* when necessary. For example, if the data source is moved to a different
* server, the property for the server can be changed. The benefit is that
* because the data source's properties can be changed, any code accessing
* that data source does not need to be changed.
* <P>
* A driver that is accessed via a <code>DataSource</code> object does not
* register itself with the <code>DriverManager</code>. Rather, a
* <code>DataSource</code> object is retrieved though a lookup operation
* and then used to create a <code>Connection</code> object. With a basic
* implementation, the connection obtained through a <code>DataSource</code>
* object is identical to a connection obtained through the
* <code>DriverManager</code> facility.
*
* @since 1.4
*/
public interface DataSource extends CommonDataSource,Wrapper {
/** {@collect.stats}
* <p>Attempts to establish a connection with the data source that
* this <code>DataSource</code> object represents.
*
* @return a connection to the data source
* @exception SQLException if a database access error occurs
*/
Connection getConnection() throws SQLException;
/** {@collect.stats}
* <p>Attempts to establish a connection with the data source that
* this <code>DataSource</code> object represents.
*
* @param username the database user on whose behalf the connection is
* being made
* @param password the user's password
* @return a connection to the data source
* @exception SQLException if a database access error occurs
* @since 1.4
*/
Connection getConnection(String username, String password)
throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
/** {@collect.stats}
* The interface that a <code>RowSet</code> object implements in order to
* present itself to a <code>RowSetReader</code> or <code>RowSetWriter</code>
* object. The <code>RowSetInternal</code> interface contains
* methods that let the reader or writer access and modify the internal
* state of the rowset.
*
* @since 1.4
*/
public interface RowSetInternal {
/** {@collect.stats}
* Retrieves the parameters that have been set for this
* <code>RowSet</code> object's command.
*
* @return an array of the current parameter values for this <code>RowSet</code>
* object's command
* @exception SQLException if a database access error occurs
*/
Object[] getParams() throws SQLException;
/** {@collect.stats}
* Retrieves the <code>Connection</code> object that was passed to this
* <code>RowSet</code> object.
*
* @return the <code>Connection</code> object passed to the rowset
* or <code>null</code> if none was passed
* @exception SQLException if a database access error occurs
*/
Connection getConnection() throws SQLException;
/** {@collect.stats}
* Sets the given <code>RowSetMetaData</code> object as the
* <code>RowSetMetaData</code> object for this <code>RowSet</code>
* object. The <code>RowSetReader</code> object associated with the rowset
* will use <code>RowSetMetaData</code> methods to set the values giving
* information about the rowset's columns.
*
* @param md the <code>RowSetMetaData</code> object that will be set with
* information about the rowset's columns
*
* @exception SQLException if a database access error occurs
*/
void setMetaData(RowSetMetaData md) throws SQLException;
/** {@collect.stats}
* Retrieves a <code>ResultSet</code> object containing the original
* value of this <code>RowSet</code> object.
* <P>
* The cursor is positioned before the first row in the result set.
* Only rows contained in the result set returned by the method
* <code>getOriginal</code> are said to have an original value.
*
* @return the original value of the rowset
* @exception SQLException if a database access error occurs
*/
public ResultSet getOriginal() throws SQLException;
/** {@collect.stats}
* Retrieves a <code>ResultSet</code> object containing the original value
* of the current row only. If the current row has no original value,
* an empty result set is returned. If there is no current row,
* an exception is thrown.
*
* @return the original value of the current row as a <code>ResultSet</code>
* object
* @exception SQLException if a database access error occurs or this method
* is called while the cursor is on the insert row, before the
* first row, or after the last row
*/
public ResultSet getOriginalRow() throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
/** {@collect.stats}
* An object that contains information about the columns in a
* <code>RowSet</code> object. This interface is
* an extension of the <code>ResultSetMetaData</code> interface with
* methods for setting the values in a <code>RowSetMetaData</code> object.
* When a <code>RowSetReader</code> object reads data into a <code>RowSet</code>
* object, it creates a <code>RowSetMetaData</code> object and initializes it
* using the methods in the <code>RowSetMetaData</code> interface. Then the
* reader passes the <code>RowSetMetaData</code> object to the rowset.
* <P>
* The methods in this interface are invoked internally when an application
* calls the method <code>RowSet.execute</code>; an application
* programmer would not use them directly.
*
* @since 1.4
*/
public interface RowSetMetaData extends ResultSetMetaData {
/** {@collect.stats}
* Sets the number of columns in the <code>RowSet</code> object to
* the given number.
*
* @param columnCount the number of columns in the <code>RowSet</code> object
* @exception SQLException if a database access error occurs
*/
void setColumnCount(int columnCount) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column is automatically numbered,
* The default is for a <code>RowSet</code> object's
* columns not to be automatically numbered.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is automatically
* numbered; <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setAutoIncrement(int columnIndex, boolean property) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column is case sensitive.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is case sensitive;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setCaseSensitive(int columnIndex, boolean property) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column can be used in a where clause.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column can be used in a
* <code>WHERE</code> clause; <code>false</code> if it cannot
*
* @exception SQLException if a database access error occurs
*/
void setSearchable(int columnIndex, boolean property) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column is a cash value.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is a cash value;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setCurrency(int columnIndex, boolean property) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column's value can be set to
* <code>NULL</code>.
* The default is <code>ResultSetMetaData.columnNullableUnknown</code>
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property one of the following constants:
* <code>ResultSetMetaData.columnNoNulls</code>,
* <code>ResultSetMetaData.columnNullable</code>, or
* <code>ResultSetMetaData.columnNullableUnknown</code>
*
* @exception SQLException if a database access error occurs
*/
void setNullable(int columnIndex, int property) throws SQLException;
/** {@collect.stats}
* Sets whether the designated column is a signed number.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is a signed number;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setSigned(int columnIndex, boolean property) throws SQLException;
/** {@collect.stats}
* Sets the designated column's normal maximum width in chars to the
* given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param size the normal maximum number of characters for
* the designated column
*
* @exception SQLException if a database access error occurs
*/
void setColumnDisplaySize(int columnIndex, int size) throws SQLException;
/** {@collect.stats}
* Sets the suggested column title for use in printouts and
* displays, if any, to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param label the column title
* @exception SQLException if a database access error occurs
*/
void setColumnLabel(int columnIndex, String label) throws SQLException;
/** {@collect.stats}
* Sets the name of the designated column to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param columnName the designated column's name
* @exception SQLException if a database access error occurs
*/
void setColumnName(int columnIndex, String columnName) throws SQLException;
/** {@collect.stats}
* Sets the name of the designated column's table's schema, if any, to
* the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param schemaName the schema name
* @exception SQLException if a database access error occurs
*/
void setSchemaName(int columnIndex, String schemaName) throws SQLException;
/** {@collect.stats}
* Sets the designated column's number of decimal digits to the
* given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param precision the total number of decimal digits
* @exception SQLException if a database access error occurs
*/
void setPrecision(int columnIndex, int precision) throws SQLException;
/** {@collect.stats}
* Sets the designated column's number of digits to the
* right of the decimal point to the given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param scale the number of digits to right of decimal point
* @exception SQLException if a database access error occurs
*/
void setScale(int columnIndex, int scale) throws SQLException;
/** {@collect.stats}
* Sets the designated column's table name, if any, to the given
* <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param tableName the column's table name
* @exception SQLException if a database access error occurs
*/
void setTableName(int columnIndex, String tableName) throws SQLException;
/** {@collect.stats}
* Sets the designated column's table's catalog name, if any, to the given
* <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param catalogName the column's catalog name
* @exception SQLException if a database access error occurs
*/
void setCatalogName(int columnIndex, String catalogName) throws SQLException;
/** {@collect.stats}
* Sets the designated column's SQL type to the one given.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param SQLType the column's SQL type
* @exception SQLException if a database access error occurs
* @see Types
*/
void setColumnType(int columnIndex, int SQLType) throws SQLException;
/** {@collect.stats}
* Sets the designated column's type name that is specific to the
* data source, if any, to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param typeName data source specific type name.
* @exception SQLException if a database access error occurs
*/
void setColumnTypeName(int columnIndex, String typeName) throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
/** {@collect.stats}
* The facility that a disconnected <code>RowSet</code> object calls on
* to populate itself with rows of data. A reader (an object implementing the
* <code>RowSetReader</code> interface) may be registered with
* a <code>RowSet</code> object that supports the reader/writer paradigm.
* When the <code>RowSet</code> object's <code>execute</code> method is
* called, it in turn calls the reader's <code>readData</code> method.
*
* @since 1.4
*/
public interface RowSetReader {
/** {@collect.stats}
* Reads the new contents of the calling <code>RowSet</code> object.
* In order to call this method, a <code>RowSet</code>
* object must have implemented the <code>RowSetInternal</code> interface
* and registered this <code>RowSetReader</code> object as its reader.
* The <code>readData</code> method is invoked internally
* by the <code>RowSet.execute</code> method for rowsets that support the
* reader/writer paradigm.
*
* <P>The <code>readData</code> method adds rows to the caller.
* It can be implemented in a wide variety of ways and can even
* populate the caller with rows from a nonrelational data source.
* In general, a reader may invoke any of the rowset's methods,
* with one exception. Calling the method <code>execute</code> will
* cause an <code>SQLException</code> to be thrown
* because <code>execute</code> may not be called recursively. Also,
* when a reader invokes <code>RowSet</code> methods, no listeners
* are notified; that is, no <code>RowSetEvent</code> objects are
* generated and no <code>RowSetListener</code> methods are invoked.
* This is true because listeners are already being notified by the method
* <code>execute</code>.
*
* @param caller the <code>RowSet</code> object (1) that has implemented the
* <code>RowSetInternal</code> interface, (2) with which this reader is
* registered, and (3) whose <code>execute</code> method called this reader
* @exception SQLException if a database access error occurs or this method
* invokes the <code>RowSet.execute</code> method
*/
void readData(RowSetInternal caller) throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
/** {@collect.stats}
* A factory for <code>XAConnection</code> objects that is used internally.
* An object that implements the <code>XADataSource</code> interface is
* typically registered with a naming service that uses the
* Java Naming and Directory Interface<sup><font size=-3>TM</font></sup>
* (JNDI).
*
* @since 1.4
*/
public interface XADataSource extends CommonDataSource {
/** {@collect.stats}
* Attempts to establish a physical database connection that can be
* used in a distributed transaction.
*
* @return an <code>XAConnection</code> object, which represents a
* physical connection to a data source, that can be used in
* a distributed transaction
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
XAConnection getXAConnection() throws SQLException;
/** {@collect.stats}
* Attempts to establish a physical database connection, using the given
* user name and password. The connection that is returned is one that
* can be used in a distributed transaction.
*
* @param user the database user on whose behalf the connection is being made
* @param password the user's password
* @return an <code>XAConnection</code> object, which represents a
* physical connection to a data source, that can be used in
* a distributed transaction
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
XAConnection getXAConnection(String user, String password)
throws SQLException;
}
| Java |
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.SQLException;
import java.io.PrintWriter;
/** {@collect.stats}
* Interface that defines the methods which are common between <code>DataSource</code>,
* <code>XADataSource</code> and <code>ConnectionPoolDataSource</code>.
*<p>
*/
public interface CommonDataSource {
/** {@collect.stats}
* <p>Retrieves the log writer for this <code>DataSource</code>
* object.
*
* <p>The log writer is a character output stream to which all logging
* and tracing messages for this data source will be
* printed. This includes messages printed by the methods of this
* object, messages printed by methods of other objects manufactured
* by this object, and so on. Messages printed to a data source
* specific log writer are not printed to the log writer associated
* with the <code>java.sql.DriverManager</code> class. When a
* <code>DataSource</code> object is
* created, the log writer is initially null; in other words, the
* default is for logging to be disabled.
*
* @return the log writer for this data source or null if
* logging is disabled
* @exception java.sql.SQLException if a database access error occurs
* @see #setLogWriter
* @since 1.4
*/
java.io.PrintWriter getLogWriter() throws SQLException;
/** {@collect.stats}
* <p>Sets the log writer for this <code>DataSource</code>
* object to the given <code>java.io.PrintWriter</code> object.
*
* <p>The log writer is a character output stream to which all logging
* and tracing messages for this data source will be
* printed. This includes messages printed by the methods of this
* object, messages printed by methods of other objects manufactured
* by this object, and so on. Messages printed to a data source-
* specific log writer are not printed to the log writer associated
* with the <code>java.sql.DriverManager</code> class. When a
* <code>DataSource</code> object is created the log writer is
* initially null; in other words, the default is for logging to be
* disabled.
*
* @param out the new log writer; to disable logging, set to null
* @exception SQLException if a database access error occurs
* @see #getLogWriter
* @since 1.4
*/
void setLogWriter(java.io.PrintWriter out) throws SQLException;
/** {@collect.stats}
* <p>Sets the maximum time in seconds that this data source will wait
* while attempting to connect to a database. A value of zero
* specifies that the timeout is the default system timeout
* if there is one; otherwise, it specifies that there is no timeout.
* When a <code>DataSource</code> object is created, the login timeout is
* initially zero.
*
* @param seconds the data source login time limit
* @exception SQLException if a database access error occurs.
* @see #getLoginTimeout
* @since 1.4
*/
void setLoginTimeout(int seconds) throws SQLException;
/** {@collect.stats}
* Gets the maximum time in seconds that this data source can wait
* while attempting to connect to a database. A value of zero
* means that the timeout is the default system timeout
* if there is one; otherwise, it means that there is no timeout.
* When a <code>DataSource</code> object is created, the login timeout is
* initially zero.
*
* @return the data source login time limit
* @exception SQLException if a database access error occurs.
* @see #setLoginTimeout
* @since 1.4
*/
int getLoginTimeout() throws SQLException;
}
| Java |
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
/** {@collect.stats}
* <P>
* An object that registers to be notified of events generated by a
* <code>PooledConnection</code> object.
* <P>
* The <code>ConnectionEventListener</code> interface is implemented by a
* connection pooling component. A connection pooling component will
* usually be provided by a JDBC driver vendor or another system software
* vendor. A JDBC driver notifies a <code>ConnectionEventListener</code>
* object when an application is finished using a pooled connection with
* which the listener has registered. The notification
* occurs after the application calls the method <code>close</code> on
* its representation of a <code>PooledConnection</code> object. A
* <code>ConnectionEventListener</code> is also notified when a
* connection error occurs due to the fact that the <code>PooledConnection</code>
* is unfit for future use---the server has crashed, for example.
* The listener is notified by the JDBC driver just before the driver throws an
* <code>SQLException</code> to the application using the
* <code>PooledConnection</code> object.
*
* @since 1.4
*/
public interface ConnectionEventListener extends java.util.EventListener {
/** {@collect.stats}
* Notifies this <code>ConnectionEventListener</code> that
* the application has called the method <code>close</code> on its
* representation of a pooled connection.
*
* @param event an event object describing the source of
* the event
*/
void connectionClosed(ConnectionEvent event);
/** {@collect.stats}
* Notifies this <code>ConnectionEventListener</code> that
* a fatal error has occurred and the pooled connection can
* no longer be used. The driver makes this notification just
* before it throws the application the <code>SQLException</code>
* contained in the given <code>ConnectionEvent</code> object.
*
* @param event an event object describing the source of
* the event and containing the <code>SQLException</code> that the
* driver is about to throw
*/
void connectionErrorOccurred(ConnectionEvent event);
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.SQLException;
/** {@collect.stats}
* <P>An <code>Event</code> object that provides information about the
* source of a connection-related event. <code>ConnectionEvent</code>
* objects are generated when an application closes a pooled connection
* and when an error occurs. The <code>ConnectionEvent</code> object
* contains two kinds of information:
* <UL>
* <LI>The pooled connection closed by the application
* <LI>In the case of an error event, the <code>SQLException</code>
* about to be thrown to the application
* </UL>
*
* @since 1.4
*/
public class ConnectionEvent extends java.util.EventObject {
/** {@collect.stats}
* <P>Constructs a <code>ConnectionEvent</code> object initialized with
* the given <code>PooledConnection</code> object. <code>SQLException</code>
* defaults to <code>null</code>.
*
* @param con the pooled connection that is the source of the event
* @throws IllegalArgumentException if <code>con</code> is null.
*/
public ConnectionEvent(PooledConnection con) {
super(con);
}
/** {@collect.stats}
* <P>Constructs a <code>ConnectionEvent</code> object initialized with
* the given <code>PooledConnection</code> object and
* <code>SQLException</code> object.
*
* @param con the pooled connection that is the source of the event
* @param ex the SQLException about to be thrown to the application
* @throws IllegalArgumentException if <code>con</code> is null.
*/
public ConnectionEvent(PooledConnection con, SQLException ex) {
super(con);
this.ex = ex;
}
/** {@collect.stats}
* <P>Retrieves the <code>SQLException</code> for this
* <code>ConnectionEvent</code> object. May be <code>null</code>.
*
* @return the SQLException about to be thrown or <code>null</code>
*/
public SQLException getSQLException() { return ex; }
/** {@collect.stats}
* The <code>SQLException</code> that the driver will throw to the
* application when an error occurs and the pooled connection is no
* longer usable.
* @serial
*/
private SQLException ex = null;
/** {@collect.stats}
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = -4843217645290030002L;
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
import java.sql.*;
import java.io.*;
import java.math.*;
import java.util.*;
/** {@collect.stats}
* The interface that adds support to the JDBC API for the
* JavaBeans<sup><font size=-2>TM</font></sup> component model.
* A rowset, which can be used as a JavaBeans component in
* a visual Bean development environment, can be created and
* configured at design time and executed at run time.
* <P>
* The <code>RowSet</code>
* interface provides a set of JavaBeans properties that allow a <code>RowSet</code>
* instance to be configured to connect to a JDBC data source and read
* some data from the data source. A group of setter methods (<code>setInt</code>,
* <code>setBytes</code>, <code>setString</code>, and so on)
* provide a way to pass input parameters to a rowset's command property.
* This command is the SQL query the rowset uses when it gets its data from
* a relational database, which is generally the case.
* <P>
* The <code>RowSet</code>
* interface supports JavaBeans events, allowing other components in an
* application to be notified when an event occurs on a rowset,
* such as a change in its value.
*
* <P>The <code>RowSet</code> interface is unique in that it is intended to be
* implemented using the rest of the JDBC API. In other words, a
* <code>RowSet</code> implementation is a layer of software that executes "on top"
* of a JDBC driver. Implementations of the <code>RowSet</code> interface can
* be provided by anyone, including JDBC driver vendors who want to
* provide a <code>RowSet</code> implementation as part of their JDBC products.
* <P>
* A <code>RowSet</code> object may make a connection with a data source and
* maintain that connection throughout its life cycle, in which case it is
* called a <i>connected</i> rowset. A rowset may also make a connection with
* a data source, get data from it, and then close the connection. Such a rowset
* is called a <i>disconnected</i> rowset. A disconnected rowset may make
* changes to its data while it is disconnected and then send the changes back
* to the original source of the data, but it must reestablish a connection to do so.
* <P>
* A disconnected rowset may have a reader (a <code>RowSetReader</code> object)
* and a writer (a <code>RowSetWriter</code> object) associated with it.
* The reader may be implemented in many different ways to populate a rowset
* with data, including getting data from a non-relational data source. The
* writer can also be implemented in many different ways to propagate changes
* made to the rowset's data back to the underlying data source.
* <P>
* Rowsets are easy to use. The <code>RowSet</code> interface extends the standard
* <code>java.sql.ResultSet</code> interface. The <code>RowSetMetaData</code>
* interface extends the <code>java.sql.ResultSetMetaData</code> interface.
* Thus, developers familiar
* with the JDBC API will have to learn a minimal number of new APIs to
* use rowsets. In addition, third-party software tools that work with
* JDBC <code>ResultSet</code> objects will also easily be made to work with rowsets.
*
* @since 1.4
*/
public interface RowSet extends ResultSet {
//-----------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// The following properties may be used to create a Connection.
//-----------------------------------------------------------------------
/** {@collect.stats}
* Retrieves the url property this <code>RowSet</code> object will use to
* create a connection if it uses the <code>DriverManager</code>
* instead of a <code>DataSource</code> object to establish the connection.
* The default value is <code>null</code>.
*
* @return a string url
* @exception SQLException if a database access error occurs
* @see #setUrl
*/
String getUrl() throws SQLException;
/** {@collect.stats}
* Sets the URL this <code>RowSet</code> object will use when it uses the
* <code>DriverManager</code> to create a connection.
*
* Setting this property is optional. If a URL is used, a JDBC driver
* that accepts the URL must be loaded before the
* rowset is used to connect to a database. The rowset will use the URL
* internally to create a database connection when reading or writing
* data. Either a URL or a data source name is used to create a
* connection, whichever was set to non null value most recently.
*
* @param url a string value; may be <code>null</code>
* @exception SQLException if a database access error occurs
* @see #getUrl
*/
void setUrl(String url) throws SQLException;
/** {@collect.stats}
* Retrieves the logical name that identifies the data source for this
* <code>RowSet</code> object.
*
* @return a data source name
* @see #setDataSourceName
* @see #setUrl
*/
String getDataSourceName();
/** {@collect.stats}
* Sets the data source name property for this <code>RowSet</code> object to the
* given <code>String</code>.
* <P>
* The value of the data source name property can be used to do a lookup of
* a <code>DataSource</code> object that has been registered with a naming
* service. After being retrieved, the <code>DataSource</code> object can be
* used to create a connection to the data source that it represents.
*
* @param name the logical name of the data source for this <code>RowSet</code>
* object; may be <code>null</code>
* @exception SQLException if a database access error occurs
* @see #getDataSourceName
*/
void setDataSourceName(String name) throws SQLException;
/** {@collect.stats}
* Retrieves the username used to create a database connection for this
* <code>RowSet</code> object.
* The username property is set at run time before calling the method
* <code>execute</code>. It is
* not usually part of the serialized state of a <code>RowSet</code> object.
*
* @return the username property
* @see #setUsername
*/
String getUsername();
/** {@collect.stats}
* Sets the username property for this <code>RowSet</code> object to the
* given <code>String</code>.
*
* @param name a user name
* @exception SQLException if a database access error occurs
* @see #getUsername
*/
void setUsername(String name) throws SQLException;
/** {@collect.stats}
* Retrieves the password used to create a database connection.
* The password property is set at run time before calling the method
* <code>execute</code>. It is not usually part of the serialized state
* of a <code>RowSet</code> object.
*
* @return the password for making a database connection
* @see #setPassword
*/
String getPassword();
/** {@collect.stats}
* Sets the database password for this <code>RowSet</code> object to
* the given <code>String</code>.
*
* @param password the password string
* @exception SQLException if a database access error occurs
* @see #getPassword
*/
void setPassword(String password) throws SQLException;
/** {@collect.stats}
* Retrieves the transaction isolation level set for this
* <code>RowSet</code> object.
*
* @return the transaction isolation level; one of
* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
* <code>Connection.TRANSACTION_READ_COMMITTED</code>,
* <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
* <code>Connection.TRANSACTION_SERIALIZABLE</code>
* @see #setTransactionIsolation
*/
int getTransactionIsolation();
/** {@collect.stats}
* Sets the transaction isolation level for this <code>RowSet</code> obejct.
*
* @param level the transaction isolation level; one of
* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
* <code>Connection.TRANSACTION_READ_COMMITTED</code>,
* <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
* <code>Connection.TRANSACTION_SERIALIZABLE</code>
* @exception SQLException if a database access error occurs
* @see #getTransactionIsolation
*/
void setTransactionIsolation(int level) throws SQLException;
/** {@collect.stats}
* Retrieves the <code>Map</code> object associated with this
* <code>RowSet</code> object, which specifies the custom mapping
* of SQL user-defined types, if any. The default is for the
* type map to be empty.
*
* @return a <code>java.util.Map</code> object containing the names of
* SQL user-defined types and the Java classes to which they are
* to be mapped
*
* @exception SQLException if a database access error occurs
* @see #setTypeMap
*/
java.util.Map<String,Class<?>> getTypeMap() throws SQLException;
/** {@collect.stats}
* Installs the given <code>java.util.Map</code> object as the default
* type map for this <code>RowSet</code> object. This type map will be
* used unless another type map is supplied as a method parameter.
*
* @param map a <code>java.util.Map</code> object containing the names of
* SQL user-defined types and the Java classes to which they are
* to be mapped
* @exception SQLException if a database access error occurs
* @see #getTypeMap
*/
void setTypeMap(java.util.Map<String,Class<?>> map) throws SQLException;
//-----------------------------------------------------------------------
// The following properties may be used to create a Statement.
//-----------------------------------------------------------------------
/** {@collect.stats}
* Retrieves this <code>RowSet</code> object's command property.
*
* The command property contains a command string, which must be an SQL
* query, that can be executed to fill the rowset with data.
* The default value is <code>null</code>.
*
* @return the command string; may be <code>null</code>
* @see #setCommand
*/
String getCommand();
/** {@collect.stats}
* Sets this <code>RowSet</code> object's command property to the given
* SQL query.
*
* This property is optional
* when a rowset gets its data from a data source that does not support
* commands, such as a spreadsheet.
*
* @param cmd the SQL query that will be used to get the data for this
* <code>RowSet</code> object; may be <code>null</code>
* @exception SQLException if a database access error occurs
* @see #getCommand
*/
void setCommand(String cmd) throws SQLException;
/** {@collect.stats}
* Retrieves whether this <code>RowSet</code> object is read-only.
* If updates are possible, the default is for a rowset to be
* updatable.
* <P>
* Attempts to update a read-only rowset will result in an
* <code>SQLException</code> being thrown.
*
* @return <code>true</code> if this <code>RowSet</code> object is
* read-only; <code>false</code> if it is updatable
* @see #setReadOnly
*/
boolean isReadOnly();
/** {@collect.stats}
* Sets whether this <code>RowSet</code> object is read-only to the
* given <code>boolean</code>.
*
* @param value <code>true</code> if read-only; <code>false</code> if
* updatable
* @exception SQLException if a database access error occurs
* @see #isReadOnly
*/
void setReadOnly(boolean value) throws SQLException;
/** {@collect.stats}
* Retrieves the maximum number of bytes that may be returned
* for certain column values.
* This limit applies only to <code>BINARY</code>,
* <code>VARBINARY</code>, <code>LONGVARBINARYBINARY</code>, <code>CHAR</code>,
* <code>VARCHAR</code>, <code>LONGVARCHAR</code>, <code>NCHAR</code>
* and <code>NVARCHAR</code> columns.
* If the limit is exceeded, the excess data is silently discarded.
*
* @return the current maximum column size limit; zero means that there
* is no limit
* @exception SQLException if a database access error occurs
* @see #setMaxFieldSize
*/
int getMaxFieldSize() throws SQLException;
/** {@collect.stats}
* Sets the maximum number of bytes that can be returned for a column
* value to the given number of bytes.
* This limit applies only to <code>BINARY</code>,
* <code>VARBINARY</code>, <code>LONGVARBINARYBINARY</code>, <code>CHAR</code>,
* <code>VARCHAR</code>, <code>LONGVARCHAR</code>, <code>NCHAR</code>
* and <code>NVARCHAR</code> columns.
* If the limit is exceeded, the excess data is silently discarded.
* For maximum portability, use values greater than 256.
*
* @param max the new max column size limit in bytes; zero means unlimited
* @exception SQLException if a database access error occurs
* @see #getMaxFieldSize
*/
void setMaxFieldSize(int max) throws SQLException;
/** {@collect.stats}
* Retrieves the maximum number of rows that this <code>RowSet</code>
* object can contain.
* If the limit is exceeded, the excess rows are silently dropped.
*
* @return the current maximum number of rows that this <code>RowSet</code>
* object can contain; zero means unlimited
* @exception SQLException if a database access error occurs
* @see #setMaxRows
*/
int getMaxRows() throws SQLException;
/** {@collect.stats}
* Sets the maximum number of rows that this <code>RowSet</code>
* object can contain to the specified number.
* If the limit is exceeded, the excess rows are silently dropped.
*
* @param max the new maximum number of rows; zero means unlimited
* @exception SQLException if a database access error occurs
* @see #getMaxRows
*/
void setMaxRows(int max) throws SQLException;
/** {@collect.stats}
* Retrieves whether escape processing is enabled for this
* <code>RowSet</code> object.
* If escape scanning is enabled, which is the default, the driver will do
* escape substitution before sending an SQL statement to the database.
*
* @return <code>true</code> if escape processing is enabled;
* <code>false</code> if it is disabled
* @exception SQLException if a database access error occurs
* @see #setEscapeProcessing
*/
boolean getEscapeProcessing() throws SQLException;
/** {@collect.stats}
* Sets escape processing for this <code>RowSet</code> object on or
* off. If escape scanning is on (the default), the driver will do
* escape substitution before sending an SQL statement to the database.
*
* @param enable <code>true</code> to enable escape processing;
* <code>false</code> to disable it
* @exception SQLException if a database access error occurs
* @see #getEscapeProcessing
*/
void setEscapeProcessing(boolean enable) throws SQLException;
/** {@collect.stats}
* Retrieves the maximum number of seconds the driver will wait for
* a statement to execute.
* If this limit is exceeded, an <code>SQLException</code> is thrown.
*
* @return the current query timeout limit in seconds; zero means
* unlimited
* @exception SQLException if a database access error occurs
* @see #setQueryTimeout
*/
int getQueryTimeout() throws SQLException;
/** {@collect.stats}
* Sets the maximum time the driver will wait for
* a statement to execute to the given number of seconds.
* If this limit is exceeded, an <code>SQLException</code> is thrown.
*
* @param seconds the new query timeout limit in seconds; zero means
* that there is no limit
* @exception SQLException if a database access error occurs
* @see #getQueryTimeout
*/
void setQueryTimeout(int seconds) throws SQLException;
/** {@collect.stats}
* Sets the type of this <code>RowSet</code> object to the given type.
* This method is used to change the type of a rowset, which is by
* default read-only and non-scrollable.
*
* @param type one of the <code>ResultSet</code> constants specifying a type:
* <code>ResultSet.TYPE_FORWARD_ONLY</code>,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
* @exception SQLException if a database access error occurs
* @see java.sql.ResultSet#getType
*/
void setType(int type) throws SQLException;
/** {@collect.stats}
* Sets the concurrency of this <code>RowSet</code> object to the given
* concurrency level. This method is used to change the concurrency level
* of a rowset, which is by default <code>ResultSet.CONCUR_READ_ONLY</code>
*
* @param concurrency one of the <code>ResultSet</code> constants specifying a
* concurrency level: <code>ResultSet.CONCUR_READ_ONLY</code> or
* <code>ResultSet.CONCUR_UPDATABLE</code>
* @exception SQLException if a database access error occurs
* @see ResultSet#getConcurrency
*/
void setConcurrency(int concurrency) throws SQLException;
//-----------------------------------------------------------------------
// Parameters
//-----------------------------------------------------------------------
/** {@collect.stats}
* The <code>RowSet</code> setter methods are used to set any input parameters
* needed by the <code>RowSet</code> object's command.
* Parameters are set at run time, as opposed to design time.
*/
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's SQL
* command to SQL <code>NULL</code>.
*
* <P><B>Note:</B> You must specify the parameter's SQL type.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param sqlType a SQL type code defined by <code>java.sql.Types</code>
* @exception SQLException if a database access error occurs
*/
void setNull(int parameterIndex, int sqlType) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to SQL <code>NULL</code>.
*
* <P><B>Note:</B> You must specify the parameter's SQL type.
*
* @param parameterName the name of the parameter
* @param sqlType the SQL type code defined in <code>java.sql.Types</code>
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setNull(String parameterName, int sqlType) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's SQL
* command to SQL <code>NULL</code>. This version of the method <code>setNull</code>
* should be used for SQL user-defined types (UDTs) and <code>REF</code> type
* parameters. Examples of UDTs include: <code>STRUCT</code>, <code>DISTINCT</code>,
* <code>JAVA_OBJECT</code>, and named array types.
*
* <P><B>Note:</B> To be portable, applications must give the
* SQL type code and the fully qualified SQL type name when specifying
* a NULL UDT or <code>REF</code> parameter. In the case of a UDT,
* the name is the type name of the parameter itself. For a <code>REF</code>
* parameter, the name is the type name of the referenced type. If
* a JDBC driver does not need the type code or type name information,
* it may ignore it.
*
* Although it is intended for UDT and <code>REF</code> parameters,
* this method may be used to set a null parameter of any JDBC type.
* If the parameter does not have a user-defined or <code>REF</code> type,
* the typeName parameter is ignored.
*
*
* @param paramIndex the first parameter is 1, the second is 2, ...
* @param sqlType a value from <code>java.sql.Types</code>
* @param typeName the fully qualified name of an SQL UDT or the type
* name of the SQL structured type being referenced by a <code>REF</code>
* type; ignored if the parameter is not a UDT or <code>REF</code> type
* @exception SQLException if a database access error occurs
*/
void setNull (int paramIndex, int sqlType, String typeName)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to SQL <code>NULL</code>.
* This version of the method <code>setNull</code> should
* be used for user-defined types and REF type parameters. Examples
* of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and
* named array types.
*
* <P><B>Note:</B> To be portable, applications must give the
* SQL type code and the fully-qualified SQL type name when specifying
* a NULL user-defined or REF parameter. In the case of a user-defined type
* the name is the type name of the parameter itself. For a REF
* parameter, the name is the type name of the referenced type. If
* a JDBC driver does not need the type code or type name information,
* it may ignore it.
*
* Although it is intended for user-defined and Ref parameters,
* this method may be used to set a null parameter of any JDBC type.
* If the parameter does not have a user-defined or REF type, the given
* typeName is ignored.
*
*
* @param parameterName the name of the parameter
* @param sqlType a value from <code>java.sql.Types</code>
* @param typeName the fully-qualified name of an SQL user-defined type;
* ignored if the parameter is not a user-defined type or
* SQL <code>REF</code> value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setNull (String parameterName, int sqlType, String typeName)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>boolean</code> value. The driver converts this to
* an SQL <code>BIT</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setBoolean(int parameterIndex, boolean x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>boolean</code> value.
* The driver converts this
* to an SQL <code>BIT</code> or <code>BOOLEAN</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @see #getBoolean
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setBoolean(String parameterName, boolean x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>byte</code> value. The driver converts this to
* an SQL <code>TINYINT</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setByte(int parameterIndex, byte x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>byte</code> value.
* The driver converts this
* to an SQL <code>TINYINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getByte
* @since 1.4
*/
void setByte(String parameterName, byte x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>short</code> value. The driver converts this to
* an SQL <code>SMALLINT</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setShort(int parameterIndex, short x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>short</code> value.
* The driver converts this
* to an SQL <code>SMALLINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getShort
* @since 1.4
*/
void setShort(String parameterName, short x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>int</code> value. The driver converts this to
* an SQL <code>INTEGER</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setInt(int parameterIndex, int x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>int</code> value.
* The driver converts this
* to an SQL <code>INTEGER</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getInt
* @since 1.4
*/
void setInt(String parameterName, int x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>long</code> value. The driver converts this to
* an SQL <code>BIGINT</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setLong(int parameterIndex, long x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>long</code> value.
* The driver converts this
* to an SQL <code>BIGINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getLong
* @since 1.4
*/
void setLong(String parameterName, long x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>float</code> value. The driver converts this to
* an SQL <code>REAL</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setFloat(int parameterIndex, float x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>float</code> value.
* The driver converts this
* to an SQL <code>FLOAT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getFloat
* @since 1.4
*/
void setFloat(String parameterName, float x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>double</code> value. The driver converts this to
* an SQL <code>DOUBLE</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setDouble(int parameterIndex, double x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>double</code> value.
* The driver converts this
* to an SQL <code>DOUBLE</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getDouble
* @since 1.4
*/
void setDouble(String parameterName, double x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.math.BigDeciaml</code> value.
* The driver converts this to
* an SQL <code>NUMERIC</code> value before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given
* <code>java.math.BigDecimal</code> value.
* The driver converts this to an SQL <code>NUMERIC</code> value when
* it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getBigDecimal
* @since 1.4
*/
void setBigDecimal(String parameterName, BigDecimal x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java <code>String</code> value. Before sending it to the
* database, the driver converts this to an SQL <code>VARCHAR</code> or
* <code>LONGVARCHAR</code> value, depending on the argument's size relative
* to the driver's limits on <code>VARCHAR</code> values.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setString(int parameterIndex, String x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java <code>String</code> value.
* The driver converts this
* to an SQL <code>VARCHAR</code> or <code>LONGVARCHAR</code> value
* (depending on the argument's
* size relative to the driver's limits on <code>VARCHAR</code> values)
* when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getString
* @since 1.4
*/
void setString(String parameterName, String x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given Java array of <code>byte</code> values. Before sending it to the
* database, the driver converts this to an SQL <code>VARBINARY</code> or
* <code>LONGVARBINARY</code> value, depending on the argument's size relative
* to the driver's limits on <code>VARBINARY</code> values.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setBytes(int parameterIndex, byte x[]) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given Java array of bytes.
* The driver converts this to an SQL <code>VARBINARY</code> or
* <code>LONGVARBINARY</code> (depending on the argument's size relative
* to the driver's limits on <code>VARBINARY</code> values) when it sends
* it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getBytes
* @since 1.4
*/
void setBytes(String parameterName, byte x[]) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.sql.Date</code> value. The driver converts this to
* an SQL <code>DATE</code> value before sending it to the database, using the
* default <code>java.util.Calendar</code> to calculate the date.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setDate(int parameterIndex, java.sql.Date x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.sql.Time</code> value. The driver converts this to
* an SQL <code>TIME</code> value before sending it to the database, using the
* default <code>java.util.Calendar</code> to calculate it.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setTime(int parameterIndex, java.sql.Time x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.sql.Timestamp</code> value. The driver converts this to
* an SQL <code>TIMESTAMP</code> value before sending it to the database, using the
* default <code>java.util.Calendar</code> to calculate it.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
void setTimestamp(int parameterIndex, java.sql.Timestamp x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value.
* The driver
* converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the
* database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getTimestamp
* @since 1.4
*/
void setTimestamp(String parameterName, java.sql.Timestamp x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.io.InputStream</code> value.
* It may be more practical to send a very large ASCII value via a
* <code>java.io.InputStream</code> rather than as a <code>LONGVARCHAR</code>
* parameter. The driver will read the data from the stream
* as needed until it reaches end-of-file.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the Java input stream that contains the ASCII parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs
*/
void setAsciiStream(int parameterIndex, java.io.InputStream x, int length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given input stream, which will have
* the specified number of bytes.
* When a very large ASCII value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code>. Data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from ASCII to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param x the Java input stream that contains the ASCII parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setAsciiStream(String parameterName, java.io.InputStream x, int length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.io.InputStream</code> value.
* It may be more practical to send a very large binary value via a
* <code>java.io.InputStream</code> rather than as a <code>LONGVARBINARY</code>
* parameter. The driver will read the data from the stream
* as needed until it reaches end-of-file.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the java input stream which contains the binary parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs
*/
void setBinaryStream(int parameterIndex, java.io.InputStream x,
int length) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given input stream, which will have
* the specified number of bytes.
* When a very large binary value is input to a <code>LONGVARBINARY</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code> object. The data will be read from the stream
* as needed until end-of-file is reached.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param x the java input stream which contains the binary parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setBinaryStream(String parameterName, java.io.InputStream x,
int length) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>java.io.Reader</code> value.
* It may be more practical to send a very large UNICODE value via a
* <code>java.io.Reader</code> rather than as a <code>LONGVARCHAR</code>
* parameter. The driver will read the data from the stream
* as needed until it reaches end-of-file.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param reader the <code>Reader</code> object that contains the UNICODE data
* to be set
* @param length the number of characters in the stream
* @exception SQLException if a database access error occurs
*/
void setCharacterStream(int parameterIndex,
Reader reader,
int length) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>Reader</code>
* object, which is the given number of characters long.
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.Reader</code> object. The data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from UNICODE to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param reader the <code>java.io.Reader</code> object that
* contains the UNICODE data used as the designated parameter
* @param length the number of characters in the stream
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void setCharacterStream(String parameterName,
java.io.Reader reader,
int length) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given input stream.
* When a very large ASCII value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code>. Data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from ASCII to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setAsciiStream</code> which takes a length parameter.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the Java input stream that contains the ASCII parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setAsciiStream(int parameterIndex, java.io.InputStream x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given input stream.
* When a very large ASCII value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code>. Data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from ASCII to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setAsciiStream</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param x the Java input stream that contains the ASCII parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setAsciiStream(String parameterName, java.io.InputStream x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given input stream.
* When a very large binary value is input to a <code>LONGVARBINARY</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code> object. The data will be read from the
* stream as needed until end-of-file is reached.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setBinaryStream</code> which takes a length parameter.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the java input stream which contains the binary parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setBinaryStream(int parameterIndex, java.io.InputStream x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given input stream.
* When a very large binary value is input to a <code>LONGVARBINARY</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code> object. The data will be read from the
* stream as needed until end-of-file is reached.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setBinaryStream</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param x the java input stream which contains the binary parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setBinaryStream(String parameterName, java.io.InputStream x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to the given <code>Reader</code>
* object.
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.Reader</code> object. The data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from UNICODE to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setCharacterStream</code> which takes a length parameter.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param reader the <code>java.io.Reader</code> object that contains the
* Unicode data
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setCharacterStream(int parameterIndex,
java.io.Reader reader) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>Reader</code>
* object.
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.Reader</code> object. The data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from UNICODE to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setCharacterStream</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param reader the <code>java.io.Reader</code> object that contains the
* Unicode data
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setCharacterStream(String parameterName,
java.io.Reader reader) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* to a <code>Reader</code> object. The
* <code>Reader</code> reads the data till end-of-file is reached. The
* driver does the necessary conversion from Java character format to
* the national character set in the database.
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setNCharacterStream</code> which takes a length parameter.
*
* @param parameterIndex of the first parameter is 1, the second is 2, ...
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur ; if a database access error occurs; or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setNCharacterStream(int parameterIndex, Reader value) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given Java <code>Object</code>. For integral values, the
* <code>java.lang</code> equivalent objects should be used (for example,
* an instance of the class <code>Integer</code> for an <code>int</code>).
*
* If the second argument is an <code>InputStream</code> then the stream must contain
* the number of bytes specified by scaleOrLength. If the second argument is a
* <code>Reader</code> then the reader must contain the number of characters specified * by scaleOrLength. If these conditions are not true the driver will generate a
* <code>SQLException</code> when the prepared statement is executed.
*
* <p>The given Java object will be converted to the targetSqlType
* before being sent to the database.
* <P>
* If the object is of a class implementing <code>SQLData</code>,
* the rowset should call the method <code>SQLData.writeSQL</code>
* to write the object to an <code>SQLOutput</code> data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
* <code>Struct</code>, <code>java.net.URL</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
*
* <p>Note that this method may be used to pass datatabase-specific
* abstract data types.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in <code>java.sql.Types</code>)
* to be sent to the database. The scale argument may further qualify this
* type.
* @param scaleOrLength for <code>java.sql.Types.DECIMAL</code>
* or <code>java.sql.Types.NUMERIC types</code>,
* this is the number of digits after the decimal point. For
* Java Object types <code>InputStream</code> and <code>Reader</code>,
* this is the length
* of the data in the stream or reader. For all other types,
* this value will be ignored.
* @exception SQLException if a database access error occurs
* @see java.sql.Types
*/
void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength)
throws SQLException;
/** {@collect.stats}
* Sets the value of the designated parameter with the given object. The second
* argument must be an object type; for integral values, the
* <code>java.lang</code> equivalent objects should be used.
*
* <p>The given Java object will be converted to the given targetSqlType
* before being sent to the database.
*
* If the object has a custom mapping (is of a class implementing the
* interface <code>SQLData</code>),
* the JDBC driver should call the method <code>SQLData.writeSQL</code> to write it
* to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
* <code>Struct</code>, <code>java.net.URL</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
* Note that this method may be used to pass datatabase-
* specific abstract data types.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be
* sent to the database. The scale argument may further qualify this type.
* @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
* this is the number of digits after the decimal point. For all other
* types, this value will be ignored.
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>,
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>,
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>,
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code>
* or <code>STRUCT</code> data type and the JDBC driver does not support
* this data type
* @see Types
* @see #getObject
* @since 1.4
*/
void setObject(String parameterName, Object x, int targetSqlType, int scale)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with a Java <code>Object</code>. For integral values, the
* <code>java.lang</code> equivalent objects should be used.
* This method is like <code>setObject</code> above, but the scale used is the scale
* of the second parameter. Scalar values have a scale of zero. Literal
* values have the scale present in the literal.
* <P>
* Even though it is supported, it is not recommended that this method
* be called with floating point input values.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in <code>java.sql.Types</code>)
* to be sent to the database
* @exception SQLException if a database access error occurs
*/
void setObject(int parameterIndex, Object x,
int targetSqlType) throws SQLException;
/** {@collect.stats}
* Sets the value of the designated parameter with the given object.
* This method is like the method <code>setObject</code>
* above, except that it assumes a scale of zero.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be
* sent to the database
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>,
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>,
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>,
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code>
* or <code>STRUCT</code> data type and the JDBC driver does not support
* this data type
* @see #getObject
* @since 1.4
*/
void setObject(String parameterName, Object x, int targetSqlType)
throws SQLException;
/** {@collect.stats}
* Sets the value of the designated parameter with the given object.
* The second parameter must be of type <code>Object</code>; therefore, the
* <code>java.lang</code> equivalent objects should be used for built-in types.
*
* <p>The JDBC specification specifies a standard mapping from
* Java <code>Object</code> types to SQL types. The given argument
* will be converted to the corresponding SQL type before being
* sent to the database.
*
* <p>Note that this method may be used to pass datatabase-
* specific abstract data types, by using a driver-specific Java
* type.
*
* If the object is of a class implementing the interface <code>SQLData</code>,
* the JDBC driver should call the method <code>SQLData.writeSQL</code>
* to write it to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
* <code>Struct</code>, <code>java.net.URL</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
* This method throws an exception if there is an ambiguity, for example, if the
* object is of a class implementing more than one of the interfaces named above.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @exception SQLException if a database access error occurs,
* this method is called on a closed <code>CallableStatement</code> or if the given
* <code>Object</code> parameter is ambiguous
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getObject
* @since 1.4
*/
void setObject(String parameterName, Object x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with a Java <code>Object</code>. For integral values, the
* <code>java.lang</code> equivalent objects should be used.
*
* <p>The JDBC specification provides a standard mapping from
* Java Object types to SQL types. The driver will convert the
* given Java object to its standard SQL mapping before sending it
* to the database.
*
* <p>Note that this method may be used to pass datatabase-specific
* abstract data types by using a driver-specific Java type.
*
* If the object is of a class implementing <code>SQLData</code>,
* the rowset should call the method <code>SQLData.writeSQL</code>
* to write the object to an <code>SQLOutput</code> data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
* <code>Struct</code>, <code>java.net.URL</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
* <P>
* An exception is thrown if there is an ambiguity, for example, if the
* object is of a class implementing more than one of these interfaces.
*
* @param parameterIndex The first parameter is 1, the second is 2, ...
* @param x The object containing the input parameter value
* @exception SQLException if a database access error occurs
*/
void setObject(int parameterIndex, Object x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>Ref</code> value. The driver will convert this
* to the appropriate <code>REF(<structured-type>)</code> value.
*
* @param i the first parameter is 1, the second is 2, ...
* @param x an object representing data of an SQL <code>REF</code> type
* @exception SQLException if a database access error occurs
*/
void setRef (int i, Ref x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>Blob</code> value. The driver will convert this
* to the <code>BLOB</code> value that the <code>Blob</code> object
* represents before sending it to the database.
*
* @param i the first parameter is 1, the second is 2, ...
* @param x an object representing a BLOB
* @exception SQLException if a database access error occurs
*/
void setBlob (int i, Blob x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>InputStream</code> object. The inputstream must contain the number
* of characters specified by length otherwise a <code>SQLException</code> will be
* generated when the <code>PreparedStatement</code> is executed.
* This method differs from the <code>setBinaryStream (int, InputStream, int)</code>
* method because it informs the driver that the parameter value should be
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
* the driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
* @param parameterIndex index of the first parameter is 1,
* the second is 2, ...
* @param inputStream An object that contains the data to set the parameter
* value to.
* @param length the number of bytes in the parameter data.
* @throws SQLException if a database access error occurs,
* this method is called on a closed <code>PreparedStatement</code>,
* if parameterIndex does not correspond
* to a parameter marker in the SQL statement, if the length specified
* is less than zero or if the number of bytes in the inputstream does not match
* the specfied length.
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>InputStream</code> object.
* This method differs from the <code>setBinaryStream (int, InputStream)</code>
* method because it informs the driver that the parameter value should be
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
* the driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
*
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setBlob</code> which takes a length parameter.
*
* @param parameterIndex index of the first parameter is 1,
* the second is 2, ...
* @param inputStream An object that contains the data to set the parameter
* value to.
* @throws SQLException if a database access error occurs,
* this method is called on a closed <code>PreparedStatement</code> or
* if parameterIndex does not correspond
* to a parameter marker in the SQL statement,
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setBlob(int parameterIndex, InputStream inputStream)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>InputStream</code> object. The <code>inputstream</code> must contain the number
* of characters specified by length, otherwise a <code>SQLException</code> will be
* generated when the <code>CallableStatement</code> is executed.
* This method differs from the <code>setBinaryStream (int, InputStream, int)</code>
* method because it informs the driver that the parameter value should be
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
* the driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
*
* @param parameterName the name of the parameter to be set
* the second is 2, ...
*
* @param inputStream An object that contains the data to set the parameter
* value to.
* @param length the number of bytes in the parameter data.
* @throws SQLException if parameterIndex does not correspond
* to a parameter marker in the SQL statement, or if the length specified
* is less than zero; if the number of bytes in the inputstream does not match
* the specfied length; if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
*
* @since 1.6
*/
void setBlob(String parameterName, InputStream inputStream, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Blob</code> object.
* The driver converts this to an SQL <code>BLOB</code> value when it
* sends it to the database.
*
* @param parameterName the name of the parameter
* @param x a <code>Blob</code> object that maps an SQL <code>BLOB</code> value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void setBlob (String parameterName, Blob x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>InputStream</code> object.
* This method differs from the <code>setBinaryStream (int, InputStream)</code>
* method because it informs the driver that the parameter value should be
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
* the driver may have to do extra work to determine whether the parameter
* data should be send to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
*
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setBlob</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param inputStream An object that contains the data to set the parameter
* value to.
* @throws SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setBlob(String parameterName, InputStream inputStream)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>Clob</code> value. The driver will convert this
* to the <code>CLOB</code> value that the <code>Clob</code> object
* represents before sending it to the database.
*
* @param i the first parameter is 1, the second is 2, ...
* @param x an object representing a CLOB
* @exception SQLException if a database access error occurs
*/
void setClob (int i, Clob x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number
* of characters specified by length otherwise a <code>SQLException</code> will be
* generated when the <code>PreparedStatement</code> is executed.
*This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
* @param parameterIndex index of the first parameter is 1, the second is 2, ...
* @param reader An object that contains the data to set the parameter value to.
* @param length the number of characters in the parameter data.
* @throws SQLException if a database access error occurs, this method is called on
* a closed <code>PreparedStatement</code>, if parameterIndex does not correspond to a parameter
* marker in the SQL statement, or if the length specified is less than zero.
*
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setClob(int parameterIndex, Reader reader, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object.
* This method differs from the <code>setCharacterStream (int, Reader)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
*
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setClob</code> which takes a length parameter.
*
* @param parameterIndex index of the first parameter is 1, the second is 2, ...
* @param reader An object that contains the data to set the parameter value to.
* @throws SQLException if a database access error occurs, this method is called on
* a closed <code>PreparedStatement</code>or if parameterIndex does not correspond to a parameter
* marker in the SQL statement
*
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setClob(int parameterIndex, Reader reader)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The <code>reader</code> must contain the number
* of characters specified by length otherwise a <code>SQLException</code> will be
* generated when the <code>CallableStatement</code> is executed.
* This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be send to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
* @param parameterName the name of the parameter to be set
* @param reader An object that contains the data to set the parameter value to.
* @param length the number of characters in the parameter data.
* @throws SQLException if parameterIndex does not correspond to a parameter
* marker in the SQL statement; if the length specified is less than zero;
* a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
*
* @since 1.6
*/
void setClob(String parameterName, Reader reader, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Clob</code> object.
* The driver converts this to an SQL <code>CLOB</code> value when it
* sends it to the database.
*
* @param parameterName the name of the parameter
* @param x a <code>Clob</code> object that maps an SQL <code>CLOB</code> value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void setClob (String parameterName, Clob x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object.
* This method differs from the <code>setCharacterStream (int, Reader)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be send to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
*
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setClob</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param reader An object that contains the data to set the parameter value to.
* @throws SQLException if a database access error occurs or this method is called on
* a closed <code>CallableStatement</code>
*
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setClob(String parameterName, Reader reader)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>Array</code> value. The driver will convert this
* to the <code>ARRAY</code> value that the <code>Array</code> object
* represents before sending it to the database.
*
* @param i the first parameter is 1, the second is 2, ...
* @param x an object representing an SQL array
* @exception SQLException if a database access error occurs
*/
void setArray (int i, Array x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>java.sql.Date</code> value. The driver will convert this
* to an SQL <code>DATE</code> value, using the given <code>java.util.Calendar</code>
* object to calculate the date.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>java.util.Calendar</code> object to use for calculating the date
* @exception SQLException if a database access error occurs
*/
void setDate(int parameterIndex, java.sql.Date x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Date</code> value
* using the default time zone of the virtual machine that is running
* the application.
* The driver converts this
* to an SQL <code>DATE</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getDate
* @since 1.4
*/
void setDate(String parameterName, java.sql.Date x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getDate
* @since 1.4
*/
void setDate(String parameterName, java.sql.Date x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>java.sql.Time</code> value. The driver will convert this
* to an SQL <code>TIME</code> value, using the given <code>java.util.Calendar</code>
* object to calculate it, before sending it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>java.util.Calendar</code> object to use for calculating the time
* @exception SQLException if a database access error occurs
*/
void setTime(int parameterIndex, java.sql.Time x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Time</code> value.
* The driver converts this
* to an SQL <code>TIME</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getTime
* @since 1.4
*/
void setTime(String parameterName, java.sql.Time x)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Time</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the time
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getTime
* @since 1.4
*/
void setTime(String parameterName, java.sql.Time x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter in this <code>RowSet</code> object's command
* with the given <code>java.sql.Timestamp</code> value. The driver will
* convert this to an SQL <code>TIMESTAMP</code> value, using the given
* <code>java.util.Calendar</code> object to calculate it, before sending it to the
* database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>java.util.Calendar</code> object to use for calculating the
* timestamp
* @exception SQLException if a database access error occurs
*/
void setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the timestamp
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the timestamp
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getTimestamp
* @since 1.4
*/
void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)
throws SQLException;
/** {@collect.stats}
* Clears the parameters set for this <code>RowSet</code> object's command.
* <P>In general, parameter values remain in force for repeated use of a
* <code>RowSet</code> object. Setting a parameter value automatically clears its
* previous value. However, in some cases it is useful to immediately
* release the resources used by the current parameter values, which can
* be done by calling the method <code>clearParameters</code>.
*
* @exception SQLException if a database access error occurs
*/
void clearParameters() throws SQLException;
//---------------------------------------------------------------------
// Reading and writing data
//---------------------------------------------------------------------
/** {@collect.stats}
* Fills this <code>RowSet</code> object with data.
* <P>
* The <code>execute</code> method may use the following properties
* to create a connection for reading data: url, data source name,
* user name, password, transaction isolation, and type map.
*
* The <code>execute</code> method may use the following properties
* to create a statement to execute a command:
* command, read only, maximum field size,
* maximum rows, escape processing, and query timeout.
* <P>
* If the required properties have not been set, an exception is
* thrown. If this method is successful, the current contents of the rowset are
* discarded and the rowset's metadata is also (re)set. If there are
* outstanding updates, they are ignored.
* <P>
* If this <code>RowSet</code> object does not maintain a continuous connection
* with its source of data, it may use a reader (a <code>RowSetReader</code>
* object) to fill itself with data. In this case, a reader will have been
* registered with this <code>RowSet</code> object, and the method
* <code>execute</code> will call on the reader's <code>readData</code>
* method as part of its implementation.
*
* @exception SQLException if a database access error occurs or any of the
* properties necessary for making a connection and creating
* a statement have not been set
*/
void execute() throws SQLException;
//--------------------------------------------------------------------
// Events
//--------------------------------------------------------------------
/** {@collect.stats}
* Registers the given listener so that it will be notified of events
* that occur on this <code>RowSet</code> object.
*
* @param listener a component that has implemented the <code>RowSetListener</code>
* interface and wants to be notified when events occur on this
* <code>RowSet</code> object
* @see #removeRowSetListener
*/
void addRowSetListener(RowSetListener listener);
/** {@collect.stats}
* Removes the specified listener from the list of components that will be
* notified when an event occurs on this <code>RowSet</code> object.
*
* @param listener a component that has been registered as a listener for this
* <code>RowSet</code> object
* @see #addRowSetListener
*/
void removeRowSetListener(RowSetListener listener);
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.SQLXML</code> object. The driver converts this to an
* SQL <code>XML</code> value when it sends it to the database.
* @param parameterIndex index of the first parameter is 1, the second is 2, ...
* @param xmlObject a <code>SQLXML</code> object that maps an SQL <code>XML</code> value
* @throws SQLException if a database access error occurs, this method
* is called on a closed result set,
* the <code>java.xml.transform.Result</code>,
* <code>Writer</code> or <code>OutputStream</code> has not been closed
* for the <code>SQLXML</code> object or
* if there is an error processing the XML value. The <code>getCause</code> method
* of the exception may provide a more detailed exception, for example, if the
* stream does not contain valid XML.
* @since 1.6
*/
void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.SQLXML</code> object. The driver converts this to an
* <code>SQL XML</code> value when it sends it to the database.
* @param parameterName the name of the parameter
* @param xmlObject a <code>SQLXML</code> object that maps an <code>SQL XML</code> value
* @throws SQLException if a database access error occurs, this method
* is called on a closed result set,
* the <code>java.xml.transform.Result</code>,
* <code>Writer</code> or <code>OutputStream</code> has not been closed
* for the <code>SQLXML</code> object or
* if there is an error processing the XML value. The <code>getCause</code> method
* of the exception may provide a more detailed exception, for example, if the
* stream does not contain valid XML.
* @since 1.6
*/
void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.RowId</code> object. The
* driver converts this to a SQL <code>ROWID</code> value when it sends it
* to the database
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @throws SQLException if a database access error occurs
*
* @since 1.6
*/
void setRowId(int parameterIndex, RowId x) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.sql.RowId</code> object. The
* driver converts this to a SQL <code>ROWID</code> when it sends it to the
* database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @throws SQLException if a database access error occurs
* @since 1.6
*/
void setRowId(String parameterName, RowId x) throws SQLException;
/** {@collect.stats}
* Sets the designated paramter to the given <code>String</code> object.
* The driver converts this to a SQL <code>NCHAR</code> or
* <code>NVARCHAR</code> or <code>LONGNVARCHAR</code> value
* (depending on the argument's
* size relative to the driver's limits on <code>NVARCHAR</code> values)
* when it sends it to the database.
*
* @param parameterIndex of the first parameter is 1, the second is 2, ...
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur ; or if a database access error occurs
* @since 1.6
*/
void setNString(int parameterIndex, String value) throws SQLException;
/** {@collect.stats}
* Sets the designated paramter to the given <code>String</code> object.
* The driver converts this to a SQL <code>NCHAR</code> or
* <code>NVARCHAR</code> or <code>LONGNVARCHAR</code>
* @param parameterName the name of the column to be set
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur; or if a database access error occurs
* @since 1.6
*/
public void setNString(String parameterName, String value)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The
* <code>Reader</code> reads the data till end-of-file is reached. The
* driver does the necessary conversion from Java character format to
* the national character set in the database.
* @param parameterIndex of the first parameter is 1, the second is 2, ...
* @param value the parameter value
* @param length the number of characters in the parameter data.
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur ; or if a database access error occurs
* @since 1.6
*/
void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The
* <code>Reader</code> reads the data till end-of-file is reached. The
* driver does the necessary conversion from Java character format to
* the national character set in the database.
* @param parameterName the name of the column to be set
* @param value the parameter value
* @param length the number of characters in the parameter data.
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur; or if a database access error occurs
* @since 1.6
*/
public void setNCharacterStream(String parameterName, Reader value, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The
* <code>Reader</code> reads the data till end-of-file is reached. The
* driver does the necessary conversion from Java character format to
* the national character set in the database.
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setNCharacterStream</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur ; if a database access error occurs; or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.6
*/
void setNCharacterStream(String parameterName, Reader value) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>java.sql.NClob</code> object. The object
* implements the <code>java.sql.NClob</code> interface. This <code>NClob</code>
* object maps to a SQL <code>NCLOB</code>.
* @param parameterName the name of the column to be set
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur; or if a database access error occurs
* @since 1.6
*/
void setNClob(String parameterName, NClob value) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The <code>reader</code> must contain the number
* of characters specified by length otherwise a <code>SQLException</code> will be
* generated when the <code>CallableStatement</code> is executed.
* This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be send to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
*
* @param parameterName the name of the parameter to be set
* @param reader An object that contains the data to set the parameter value to.
* @param length the number of characters in the parameter data.
* @throws SQLException if parameterIndex does not correspond to a parameter
* marker in the SQL statement; if the length specified is less than zero;
* if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur; if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void setNClob(String parameterName, Reader reader, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object.
* This method differs from the <code>setCharacterStream (int, Reader)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be send to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setNClob</code> which takes a length parameter.
*
* @param parameterName the name of the parameter
* @param reader An object that contains the data to set the parameter value to.
* @throws SQLException if the driver does not support national character sets;
* if the driver can detect that a data conversion
* error could occur; if a database access error occurs or
* this method is called on a closed <code>CallableStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setNClob(String parameterName, Reader reader)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number
* of characters specified by length otherwise a <code>SQLException</code> will be
* generated when the <code>PreparedStatement</code> is executed.
* This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
* @param parameterIndex index of the first parameter is 1, the second is 2, ...
* @param reader An object that contains the data to set the parameter value to.
* @param length the number of characters in the parameter data.
* @throws SQLException if parameterIndex does not correspond to a parameter
* marker in the SQL statement; if the length specified is less than zero;
* if the driver does not support national character sets;
* if the driver can detect that a data conversion
* error could occur; if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>java.sql.NClob</code> object. The driver converts this to a
* SQL <code>NCLOB</code> value when it sends it to the database.
* @param parameterIndex of the first parameter is 1, the second is 2, ...
* @param value the parameter value
* @throws SQLException if the driver does not support national
* character sets; if the driver can detect that a data conversion
* error could occur ; or if a database access error occurs
* @since 1.6
*/
void setNClob(int parameterIndex, NClob value) throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to a <code>Reader</code> object.
* This method differs from the <code>setCharacterStream (int, Reader)</code> method
* because it informs the driver that the parameter value should be sent to
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
* driver may have to do extra work to determine whether the parameter
* data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if
* it might be more efficient to use a version of
* <code>setNClob</code> which takes a length parameter.
*
* @param parameterIndex index of the first parameter is 1, the second is 2, ...
* @param reader An object that contains the data to set the parameter value to.
* @throws SQLException if parameterIndex does not correspond to a parameter
* marker in the SQL statement;
* if the driver does not support national character sets;
* if the driver can detect that a data conversion
* error could occur; if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
*
* @since 1.6
*/
void setNClob(int parameterIndex, Reader reader)
throws SQLException;
/** {@collect.stats}
* Sets the designated parameter to the given <code>java.net.URL</code> value.
* The driver converts this to an SQL <code>DATALINK</code> value
* when it sends it to the database.
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the <code>java.net.URL</code> object to be set
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
* @since 1.4
*/
void setURL(int parameterIndex, java.net.URL x) throws SQLException;
}
| Java |
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Created on Apr 28, 2005
*/
package javax.sql;
/** {@collect.stats}
* An object that registers to be notified of events that occur on PreparedStatements
* that are in the Statement pool.
* <p>
* The JDBC 3.0 specification added the maxStatements
* <code>ConnectionPooledDataSource</code> property to provide a standard mechanism for
* enabling the pooling of <code>PreparedStatements</code>
* and to specify the size of the statement
* pool. However, there was no way for a driver to notify an external
* statement pool when a <code>PreparedStatement</code> becomes invalid. For some databases, a
* statement becomes invalid if a DDL operation is performed that affects the
* table. For example an application may create a temporary table to do some work
* on the table and then destroy it. It may later recreate the same table when
* it is needed again. Some databases will invalidate any prepared statements
* that reference the temporary table when the table is dropped.
* <p>
* Similar to the methods defined in the <code>ConnectionEventListener</code> interface,
* the driver will call the <code>StatementEventListener.statementErrorOccurred</code>
* method prior to throwing any exceptions when it detects a statement is invalid.
* The driver will also call the <code>StatementEventListener.statementClosed</code>
* method when a <code>PreparedStatement</code> is closed.
* <p>
* Methods which allow a component to register a StatementEventListener with a
* <code>PooledConnection</code> have been added to the <code>PooledConnection</code> interface.
* <p>
* @since 1.6
*/
public interface StatementEventListener extends java.util.EventListener{
/** {@collect.stats}
* The driver calls this method on all <code>StatementEventListener</code>s registered on the connection when it detects that a
* <code>PreparedStatement</code> is closed.
*
* @param event an event object describing the source of
* the event and that the <code>PreparedStatement</code> was closed.
* @since 1.6
*/
void statementClosed(StatementEvent event);
/** {@collect.stats}
* The driver calls this method on all <code>StatementEventListener</code>s
* registered on the connection when it detects that a
* <code>PreparedStatement</code> is invalid. The driver calls this method
* just before it throws the <code>SQLException</code>,
* contained in the given event, to the application.
* <p>
* @param event an event object describing the source of the event,
* the statement that is invalid and the exception the
* driver is about to throw. The source of the event is
* the <code>PooledConnection</code> which the invalid <code>PreparedStatement</code>
* is associated with.
* <p>
* @since 1.6
*/
void statementErrorOccurred(StatementEvent event);
}
| Java |
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql;
/** {@collect.stats}
* An <code>Event</code> object generated when an event occurs to a
* <code>RowSet</code> object. A <code>RowSetEvent</code> object is
* generated when a single row in a rowset is changed, the whole rowset
* is changed, or the rowset cursor moves.
* <P>
* When an event occurs on a <code>RowSet</code> object, one of the
* <code>RowSetListener</code> methods will be sent to all registered
* listeners to notify them of the event. An <code>Event</code> object
* is supplied to the <code>RowSetListener</code> method so that the
* listener can use it to find out which <code>RowSet</code> object is
* the source of the event.
*
* @since 1.4
*/
public class RowSetEvent extends java.util.EventObject {
/** {@collect.stats}
* Constructs a <code>RowSetEvent</code> object initialized with the
* given <code>RowSet</code> object.
*
* @param source the <code>RowSet</code> object whose data has changed or
* whose cursor has moved
* @throws IllegalArgumentException if <code>source</code> is null.
*/
public RowSetEvent(RowSet source)
{ super(source); }
/** {@collect.stats}
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = -1875450876546332005L;
}
| Java |
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql.rowset;
import java.sql.SQLException;
/** {@collect.stats}
* <h3>1.0 Background</h3>
* The <code>Joinable</code> interface provides the methods for getting and
* setting a match column, which is the basis for forming the SQL <code>JOIN</code>
* formed by adding <code>RowSet</code> objects to a <code>JoinRowSet</code>
* object.
* <P>
* Any standard <code>RowSet</code> implementation <b>may</b> implement
* the <code>Joinable</code> interface in order to be
* added to a <code>JoinRowSet</code> object. Implementing this interface gives
* a <code>RowSet</code> object the ability to use <code>Joinable</code> methods,
* which set, retrieve, and get information about match columns. An
* application may add a
* <code>RowSet</code> object that has not implemented the <code>Joinable</code>
* interface to a <code>JoinRowSet</code> object, but to do so it must use one
* of the <code>JoinRowSet.addRowSet</code> methods that takes both a
* <code>RowSet</code> object and a match column or an array of <code>RowSet</code>
* objects and an array of match columns.
* <P>
* To get access to the methods in the <code>Joinable</code> interface, a
* <code>RowSet</code> object implements at least one of the
* five standard <code>RowSet</code> interfaces and also implements the
* <code>Joinable</code> interface. In addition, most <code>RowSet</code>
* objects extend the <code>BaseRowSet</code> class. For example:
* <pre>
* class MyRowSetImpl extends BaseRowSet implements CachedRowSet, Joinable {
* :
* :
* }
* </pre>
* <P>
* <h3>2.0 Usage Guidelines</h3>
* <P>
* The methods in the <code>Joinable</code> interface allow a <code>RowSet</code> object
* to set a match column, retrieve a match column, or unset a match column, which is
* the column upon which an SQL <code>JOIN</code> can be based.
* An instance of a class that implements these methods can be added to a
* <code>JoinRowSet</code> object to allow an SQL <code>JOIN</code> relationship to
* be established.
* <p>
* <pre>
* CachedRowSet crs = new MyRowSetImpl();
* crs.populate((ResultSet)rs);
* (Joinable)crs.setMatchColumnIndex(1);
*
* JoinRowSet jrs = new JoinRowSetImpl();
* jrs.addRowSet(crs);
* </pre>
* In the previous example, <i>crs</i> is a <code>CachedRowSet</code> object that
* has emplemented the <code>Joinable</code> interface. In the following example,
* <i>crs2</i> has not, so it must supply the match column as an argument to the
* <code>addRowSet</code> method. This example assumes that column 1 is the match
* column.
* <PRE>
* CachedRowSet crs2 = new MyRowSetImpl();
* crs2.populate((ResultSet)rs);
*
* JoinRowSet jrs2 = new JoinRowSetImpl();
* jrs2.addRowSet(crs2, 1);
* </PRE>
* <p>
* The <code>JoinRowSet</code> interface makes it possible to get data from one or
* more <code>RowSet</code> objects consolidated into one table without having to incur
* the expense of creating a connection to a database. It is therefore ideally suited
* for use by disconnected <code>RowSet</code> objects. Nevertheless, any
* <code>RowSet</code> object <b>may</b> implement this interface
* regardless of whether it is connected or disconnected. Note that a
* <code>JdbcRowSet</code> object, being always connected to its data source, can
* become part of an SQL <code>JOIN</code> directly without having to become part
* of a <code>JoinRowSet</code> object.
* <P>
* <h3>3.0 Managing Multiple Match Columns</h3>
* The index array passed into the <code>setMatchColumn</code> methods indicates
* how many match columns are being set (the length of the array) in addition to
* which columns will be used for the match. For example:
* <pre>
* int[] i = {1, 2, 4, 7}; // indicates four match columns, with column
* // indexes 1, 2, 4, 7 participating in the JOIN.
* Joinable.setMatchColumn(i);
* </pre>
* Subsequent match columns may be added as follows to a different <code>Joinable</code>
* object (a <code>RowSet</code> object that has implemented the <code>Joinable</code>
* interface).
* <pre>
* int[] w = {3, 2, 5, 3};
* Joinable2.setMatchColumn(w);
* </pre>
* When an application adds two or more <code>RowSet</code> objects to a
* <code>JoinRowSet</code> object, the order of the indexes in the array is
* particularly important. Each index of
* the array maps directly to the corresponding index of the previously added
* <code>RowSet</code> object. If overlap or underlap occurs, the match column
* data is maintained in the event an additional <code>Joinable</code> RowSet is
* added and needs to relate to the match column data. Therefore, applications
* can set multiple match columns in any order, but
* this order has a direct effect on the outcome of the <code>SQL</code> JOIN.
* <p>
* This assertion applies in exactly the same manner when column names are used
* rather than column indexes to indicate match columns.
*
* @see JoinRowSet
* @author Jonathan Bruce
*/
public interface Joinable {
/** {@collect.stats}
* Sets the designated column as the match column for this <code>RowSet</code>
* object. A <code>JoinRowSet</code> object can now add this <code>RowSet</code>
* object based on the match column.
* <p>
* Sub-interfaces such as the <code>CachedRowSet</code><sup><font size=-2>TM</font></sup>
* interface define the method <code>CachedRowSet.setKeyColumns</code>, which allows
* primary key semantics to be enforced on specific columns.
* Implementations of the <code>setMatchColumn(int columnIdx)</code> method
* should ensure that the constraints on the key columns are maintained when
* a <code>CachedRowSet</code> object sets a primary key column as a match column.
*
* @param columnIdx an <code>int</code> identifying the index of the column to be
* set as the match column
* @throws SQLException if an invalid column index is set
* @see #setMatchColumn(int[])
* @see #unsetMatchColumn(int)
*
*/
public void setMatchColumn(int columnIdx) throws SQLException;
/** {@collect.stats}
* Sets the designated columns as the match column for this <code>RowSet</code>
* object. A <code>JoinRowSet</code> object can now add this <code>RowSet</code>
* object based on the match column.
*
* @param columnIdxes an array of <code>int</code> identifying the indexes of the
* columns to be set as the match columns
* @throws SQLException if an invalid column index is set
* @see #setMatchColumn(int[])
* @see #unsetMatchColumn(int[])
*/
public void setMatchColumn(int[] columnIdxes) throws SQLException;
/** {@collect.stats}
* Sets the designated column as the match column for this <code>RowSet</code>
* object. A <code>JoinRowSet</code> object can now add this <code>RowSet</code>
* object based on the match column.
* <p>
* Subinterfaces such as the <code>CachedRowSet</code> interface define
* the method <code>CachedRowSet.setKeyColumns</code>, which allows
* primary key semantics to be enforced on specific columns.
* Implementations of the <code>setMatchColumn(String columnIdx)</code> method
* should ensure that the constraints on the key columns are maintained when
* a <code>CachedRowSet</code> object sets a primary key column as a match column.
*
* @param columnName a <code>String</code> object giving the name of the column
* to be set as the match column
* @throws SQLException if an invalid column name is set, the column name
* is a null, or the column name is an empty string
* @see #unsetMatchColumn
* @see #setMatchColumn(int[])
*/
public void setMatchColumn(String columnName) throws SQLException;
/** {@collect.stats}
* Sets the designated columns as the match column for this <code>RowSet</code>
* object. A <code>JoinRowSet</code> object can now add this <code>RowSet</code>
* object based on the match column.
*
* @param columnNames an array of <code>String</code> objects giving the names
* of the column to be set as the match columns
* @throws SQLException if an invalid column name is set, the column name
* is a null, or the column name is an empty string
* @see #unsetMatchColumn
* @see #setMatchColumn(int[])
*/
public void setMatchColumn(String[] columnNames) throws SQLException;
/** {@collect.stats}
* Retrieves the indexes of the match columns that were set for this
* <code>RowSet</code> object with the method
* <code>setMatchColumn(int[] columnIdxes)</code>.
*
* @return an <code>int</code> array identifying the indexes of the columns
* that were set as the match columns for this <code>RowSet</code> object
* @throws SQLException if no match column has been set
* @see #setMatchColumn
* @see #unsetMatchColumn
*/
public int[] getMatchColumnIndexes() throws SQLException;
/** {@collect.stats}
* Retrieves the names of the match columns that were set for this
* <code>RowSet</code> object with the method
* <code>setMatchColumn(String [] columnNames)</code>.
*
* @return an array of <code>String</code> objects giving the names of the columns
* set as the match columns for this <code>RowSet</code> object
* @throws SQLException if no match column has been set
* @see #setMatchColumn
* @see #unsetMatchColumn
*
*/
public String[] getMatchColumnNames() throws SQLException;
/** {@collect.stats}
* Unsets the designated column as the match column for this <code>RowSet</code>
* object.
* <P>
* <code>RowSet</code> objects that implement the <code>Joinable</code> interface
* must ensure that a key-like constraint continues to be enforced until the
* method <code>CachedRowSet.unsetKeyColumns</code> has been called on the
* designated column.
*
* @param columnIdx an <code>int</code> that identifies the index of the column
* that is to be unset as a match column
* @throws SQLException if an invalid column index is designated or if
* the designated column was not previously set as a match
* column
* @see #setMatchColumn
*/
public void unsetMatchColumn(int columnIdx) throws SQLException;
/** {@collect.stats}
* Unsets the designated columns as the match column for this <code>RowSet</code>
* object.
*
* @param columnIdxes an arrary of <code>int</code> that identifies the indexes
* of the columns that are to be unset as match columns
* @throws SQLException if an invalid column index is designated or if
* the designated column was not previously set as a match
* column
* @see #setMatchColumn
*/
public void unsetMatchColumn(int[] columnIdxes) throws SQLException;
/** {@collect.stats}
* Unsets the designated column as the match column for this <code>RowSet</code>
* object.
* <P>
* <code>RowSet</code> objects that implement the <code>Joinable</code> interface
* must ensure that a key-like constraint continues to be enforced until the
* method <code>CachedRowSet.unsetKeyColumns</code> has been called on the
* designated column.
*
* @param columnName a <code>String</code> object giving the name of the column
* that is to be unset as a match column
* @throws SQLException if an invalid column name is designated or
* the designated column was not previously set as a match
* column
* @see #setMatchColumn
*/
public void unsetMatchColumn(String columnName) throws SQLException;
/** {@collect.stats}
* Unsets the designated columns as the match columns for this <code>RowSet</code>
* object.
*
* @param columnName an array of <code>String</code> objects giving the names of
* the columns that are to be unset as the match columns
* @throws SQLException if an invalid column name is designated or the
* designated column was not previously set as a match column
* @see #setMatchColumn
*/
public void unsetMatchColumn(String[] columnName) throws SQLException;
}
| Java |
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sql.rowset;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.io.*;
import java.math.*;
import java.util.*;
import javax.sql.rowset.spi.*;
/** {@collect.stats}
* The interface that all standard implementations of
* <code>CachedRowSet</code> must implement.
* <P>
* The reference implementation of the <code>CachedRowSet</code> interface provided
* by Sun Microsystems is a standard implementation. Developers may use this implementation
* just as it is, they may extend it, or they may choose to write their own implementations
* of this interface.
* <P>
* A <code>CachedRowSet</code> object is a container for rows of data
* that caches its rows in memory, which makes it possible to operate without always being
* connected to its data source. Further, it is a
* JavaBeans<sup><font size=-2>TM</font></sup> component and is scrollable,
* updatable, and serializable. A <code>CachedRowSet</code> object typically
* contains rows from a result set, but it can also contain rows from any file
* with a tabular format, such as a spread sheet. The reference implementation
* supports getting data only from a <code>ResultSet</code> object, but
* developers can extend the <code>SyncProvider</code> implementations to provide
* access to other tabular data sources.
* <P>
* An application can modify the data in a <code>CachedRowSet</code> object, and
* those modifications can then be propagated back to the source of the data.
* <P>
* A <code>CachedRowSet</code> object is a <i>disconnected</i> rowset, which means
* that it makes use of a connection to its data source only briefly. It connects to its
* data source while it is reading data to populate itself with rows and again
* while it is propagating changes back to its underlying data source. The rest
* of the time, a <code>CachedRowSet</code> object is disconnected, including
* while its data is being modified. Being disconnected makes a <code>RowSet</code>
* object much leaner and therefore much easier to pass to another component. For
* example, a disconnected <code>RowSet</code> object can be serialized and passed
* over the wire to a thin client such as a personal digital assistant (PDA).
* <P>
*
* <h3>1.0 Creating a <code>CachedRowSet</code> Object</h3>
* The following line of code uses the default constructor for
* <code>CachedRowSet</code>
* supplied in the reference implementation (RI) to create a default
* <code>CachedRowSet</code> object.
* <PRE>
* CachedRowSetImpl crs = new CachedRowSetImpl();
* </PRE>
* This new <code>CachedRowSet</code> object will have its properties set to the
* default properties of a <code>BaseRowSet</code> object, and, in addition, it will
* have an <code>RIOptimisticProvider</code> object as its synchronization provider.
* <code>RIOptimisticProvider</code>, one of two <code>SyncProvider</code>
* implementations included in the RI, is the default provider that the
* <code>SyncFactory</code> singleton will supply when no synchronization
* provider is specified.
* <P>
* A <code>SyncProvider</code> object provides a <code>CachedRowSet</code> object
* with a reader (a <code>RowSetReader</code> object) for reading data from a
* data source to populate itself with data. A reader can be implemented to read
* data from a <code>ResultSet</code> object or from a file with a tabular format.
* A <code>SyncProvider</code> object also provides
* a writer (a <code>RowSetWriter</code> object) for synchronizing any
* modifications to the <code>CachedRowSet</code> object's data made while it was
* disconnected with the data in the underlying data source.
* <P>
* A writer can be implemented to exercise various degrees of care in checking
* for conflicts and in avoiding them.
* (A conflict occurs when a value in the data source has been changed after
* the rowset populated itself with that value.)
* The <code>RIOptimisticProvider</code> implementation assumes there will be
* few or no conflicts and therefore sets no locks. It updates the data source
* with values from the <code>CachedRowSet</code> object only if there are no
* conflicts.
* Other writers can be implemented so that they always write modified data to
* the data source, which can be accomplished either by not checking for conflicts
* or, on the other end of the spectrum, by setting locks sufficient to prevent data
* in the data source from being changed. Still other writer implementations can be
* somewhere in between.
* <P>
* A <code>CachedRowSet</code> object may use any
* <code>SyncProvider</code> implementation that has been registered
* with the <code>SyncFactory</code> singleton. An application
* can find out which <code>SyncProvider</code> implementations have been
* registered by calling the following line of code.
* <PRE>
* java.util.Enumeration providers = SyncFactory.getRegisteredProviders();
* </PRE>
* <P>
* There are two ways for a <code>CachedRowSet</code> object to specify which
* <code>SyncProvider</code> object it will use.
* <UL)
* <LI>Supplying the name of the implementation to the constructor<BR>
* The following line of code creates the <code>CachedRowSet</code>
* object <i>crs2</i> that is initialized with default values except that its
* <code>SyncProvider</code> object is the one specified.
* <PRE>
* CachedRowSetImpl crs2 = new CachedRowSetImpl(
* "com.fred.providers.HighAvailabilityProvider");
* </PRE>
* <LI>Setting the <code>SyncProvider</code> using the <code>CachedRowSet</code>
* method <code>setSyncProvider</code><BR>
* The following line of code resets the <code>SyncProvider</code> object
* for <i>crs</i>, the <code>CachedRowSet</code> object created with the
* default constructor.
* <PRE>
* crs.setSyncProvider("com.fred.providers.HighAvailabilityProvider");
* </PRE>
* </UL)
* See the comments for <code>SyncFactory</code> and <code>SyncProvider</code> for
* more details.
*
* <P>
* <h3>2.0 Retrieving Data from a <code>CachedRowSet</code> Object</h3>
* Data is retrieved from a <code>CachedRowSet</code> object by using the
* getter methods inherited from the <code>ResultSet</code>
* interface. The following examples, in which <code>crs</code> is a
* <code>CachedRowSet</code>
* object, demonstrate how to iterate through the rows, retrieving the column
* values in each row. The first example uses the version of the
* getter methods that take a column number; the second example
* uses the version that takes a column name. Column numbers are generally
* used when the <code>RowSet</code> object's command
* is of the form <code>SELECT * FROM TABLENAME</code>; column names are most
* commonly used when the command specifies columns by name.
* <PRE>
* while (crs.next()) {
* String name = crs.getString(1);
* int id = crs.getInt(2);
* Clob comment = crs.getClob(3);
* short dept = crs.getShort(4);
* System.out.println(name + " " + id + " " + comment + " " + dept);
* }
* </PRE>
*
* <PRE>
* while (crs.next()) {
* String name = crs.getString("NAME");
* int id = crs.getInt("ID");
* Clob comment = crs.getClob("COM");
* short dept = crs.getShort("DEPT");
* System.out.println(name + " " + id + " " + comment + " " + dept);
* }
* </PRE>
* <h4>2.1 Retrieving <code>RowSetMetaData</code></h4>
* An application can get information about the columns in a <code>CachedRowSet</code>
* object by calling <code>ResultSetMetaData</code> and <code>RowSetMetaData</code>
* methods on a <code>RowSetMetaData</code> object. The following code fragment,
* in which <i>crs</i> is a <code>CachedRowSet</code> object, illustrates the process.
* The first line creates a <code>RowSetMetaData</code> object with information
* about the columns in <i>crs</i>. The method <code>getMetaData</code>,
* inherited from the <code>ResultSet</code> interface, returns a
* <code>ResultSetMetaData</code> object, which is cast to a
* <code>RowSetMetaData</code> object before being assigned to the variable
* <i>rsmd</i>. The second line finds out how many columns <i>jrs</i> has, and
* the third line gets the JDBC type of values stored in the second column of
* <code>jrs</code>.
* <PRE>
* RowSetMetaData rsmd = (RowSetMetaData)crs.getMetaData();
* int count = rsmd.getColumnCount();
* int type = rsmd.getColumnType(2);
* </PRE>
* The <code>RowSetMetaData</code> interface differs from the
* <code>ResultSetMetaData</code> interface in two ways.
* <UL>
* <LI><i>It includes <code>setter</code> methods:</i> A <code>RowSet</code>
* object uses these methods internally when it is populated with data from a
* different <code>ResultSet</code> object.
* <P>
* <LI><i>It contains fewer <code>getter</code> methods:</i> Some
* <code>ResultSetMetaData</code> methods to not apply to a <code>RowSet</code>
* object. For example, methods retrieving whether a column value is writable
* or read only do not apply because all of a <code>RowSet</code> object's
* columns will be writable or read only, depending on whether the rowset is
* updatable or not.
* </UL>
* NOTE: In order to return a <code>RowSetMetaData</code> object, implementations must
* override the <code>getMetaData()</code> method defined in
* <code>java.sql.ResultSet</code> and return a <code>RowSetMetaData</code> object.
*
* <h3>3.0 Updating a <code>CachedRowSet</code> Object</h3>
* Updating a <code>CachedRowSet</code> object is similar to updating a
* <code>ResultSet</code> object, but because the rowset is not connected to
* its data source while it is being updated, it must take an additional step
* to effect changes in its underlying data source. After calling the method
* <code>updateRow</code> or <code>insertRow</code>, a
* <code>CachedRowSet</code>
* object must also call the method <code>acceptChanges</code> to have updates
* written to the data source. The following example, in which the cursor is
* on a row in the <code>CachedRowSet</code> object <i>crs</i>, shows
* the code required to update two column values in the current row and also
* update the <code>RowSet</code> object's underlying data source.
* <PRE>
* crs.updateShort(3, 58);
* crs.updateInt(4, 150000);
* crs.updateRow();
* crs.acceptChanges();
* </PRE>
* <P>
* The next example demonstrates moving to the insert row, building a new
* row on the insert row, inserting it into the rowset, and then calling the
* method <code>acceptChanges</code> to add the new row to the underlying data
* source. Note that as with the getter methods, the updater methods may take
* either a column index or a column name to designate the column being acted upon.
* <PRE>
* crs.moveToInsertRow();
* crs.updateString("Name", "Shakespeare");
* crs.updateInt("ID", 10098347);
* crs.updateShort("Age", 58);
* crs.updateInt("Sal", 150000);
* crs.insertRow();
* crs.moveToCurrentRow();
* crs.acceptChanges();
* </PRE>
* <P>
* NOTE: Where the <code>insertRow()</code> method inserts the contents of a
* <code>CachedRowSet</code> object's insert row is implementation-defined.
* The reference implementation for the <code>CachedRowSet</code> interface
* inserts a new row immediately following the current row, but it could be
* implemented to insert new rows in any number of other places.
* <P>
* Another thing to note about these examples is how they use the method
* <code>acceptChanges</code>. It is this method that propagates changes in
* a <code>CachedRowSet</code> object back to the underlying data source,
* calling on the <code>RowSet</code> object's writer internally to write
* changes to the data source. To do this, the writer has to incur the expense
* of establishing a connection with that data source. The
* preceding two code fragments call the method <code>acceptChanges</code>
* immediately after calling <code>updateRow</code> or <code>insertRow</code>.
* However, when there are multiple rows being changed, it is more efficient to call
* <code>acceptChanges</code> after all calls to <code>updateRow</code>
* and <code>insertRow</code> have been made. If <code>acceptChanges</code>
* is called only once, only one connection needs to be established.
* <P>
* <h3>4.0 Updating the Underlying Data Source</h3>
* When the method <code>acceptChanges</code> is executed, the
* <code>CachedRowSet</code> object's writer, a <code>RowSetWriterImpl</code>
* object, is called behind the scenes to write the changes made to the
* rowset to the underlying data source. The writer is implemented to make a
* connection to the data source and write updates to it.
* <P>
* A writer is made available through an implementation of the
* <code>SyncProvider</code> interface, as discussed in section 1,
* "Creating a <code>CachedRowSet</code> Object."
* The default reference implementation provider, <code>RIOptimisticProvider</code>,
* has its writer implemented to use an optimistic concurrency control
* mechanism. That is, it maintains no locks in the underlying database while
* the rowset is disconnected from the database and simply checks to see if there
* are any conflicts before writing data to the data source. If there are any
* conflicts, it does not write anything to the data source.
* <P>
* The reader/writer facility
* provided by the <code>SyncProvider</code> class is pluggable, allowing for the
* customization of data retrieval and updating. If a different concurrency
* control mechanism is desired, a different implementation of
* <code>SyncProvider</code> can be plugged in using the method
* <code>setSyncProvider</code>.
* <P>
* In order to use the optimistic concurrency control routine, the
* <code>RIOptismisticProvider</code> maintains both its current
* value and its original value (the value it had immediately preceding the
* current value). Note that if no changes have been made to the data in a
* <code>RowSet</code> object, its current values and its original values are the same,
* both being the values with which the <code>RowSet</code> object was initially
* populated. However, once any values in the <code>RowSet</code> object have been
* changed, the current values and the original values will be different, though at
* this stage, the original values are still the initial values. With any subsequent
* changes to data in a <code>RowSet</code> object, its original values and current
* values will still differ, but its original values will be the values that
* were previously the current values.
* <P>
* Keeping track of original values allows the writer to compare the <code>RowSet</code>
* object's original value with the value in the database. If the values in
* the database differ from the <code>RowSet</code> object's original values, which means that
* the values in the database have been changed, there is a conflict.
* Whether a writer checks for conflicts, what degree of checking it does, and how
* it handles conflicts all depend on how it is implemented.
* <P>
* <h3>5.0 Registering and Notifying Listeners</h3>
* Being JavaBeans components, all rowsets participate in the JavaBeans event
* model, inheriting methods for registering listeners and notifying them of
* changes from the <code>BaseRowSet</code> class. A listener for a
* <code>CachedRowSet</code> object is a component that wants to be notified
* whenever there is a change in the rowset. For example, if a
* <code>CachedRowSet</code> object contains the results of a query and
* those
* results are being displayed in, say, a table and a bar graph, the table and
* bar graph could be registered as listeners with the rowset so that they can
* update themselves to reflect changes. To become listeners, the table and
* bar graph classes must implement the <code>RowSetListener</code> interface.
* Then they can be added to the <Code>CachedRowSet</code> object's list of
* listeners, as is illustrated in the following lines of code.
* <PRE>
* crs.addRowSetListener(table);
* crs.addRowSetListener(barGraph);
* </PRE>
* Each <code>CachedRowSet</code> method that moves the cursor or changes
* data also notifies registered listeners of the changes, so
* <code>table</code> and <code>barGraph</code> will be notified when there is
* a change in <code>crs</code>.
* <P>
* <h3>6.0 Passing Data to Thin Clients</h3>
* One of the main reasons to use a <code>CachedRowSet</code> object is to
* pass data between different components of an application. Because it is
* serializable, a <code>CachedRowSet</code> object can be used, for example,
* to send the result of a query executed by an enterprise JavaBeans component
* running in a server environment over a network to a client running in a
* web browser.
* <P>
* While a <code>CachedRowSet</code> object is disconnected, it can be much
* leaner than a <code>ResultSet</code> object with the same data.
* As a result, it can be especially suitable for sending data to a thin client
* such as a PDA, where it would be inappropriate to use a JDBC driver
* due to resource limitations or security considerations.
* Thus, a <code>CachedRowSet</code> object provides a means to "get rows in"
* without the need to implement the full JDBC API.
* <P>
* <h3>7.0 Scrolling and Updating</h3>
* A second major use for <code>CachedRowSet</code> objects is to provide
* scrolling and updating for <code>ResultSet</code> objects that
* do not provide these capabilities themselves. In other words, a
* <code>CachedRowSet</code> object can be used to augment the
* capabilities of a JDBC technology-enabled driver (hereafter called a
* "JDBC driver") when the DBMS does not provide full support for scrolling and
* updating. To achieve the effect of making a non-scrollble and read-only
* <code>ResultSet</code> object scrollable and updatable, a programmer
* simply needs to create a <code>CachedRowSet</code> object populated
* with that <code>ResultSet</code> object's data. This is demonstrated
* in the following code fragment, where <code>stmt</code> is a
* <code>Statement</code> object.
* <PRE>
* ResultSet rs = stmt.executeQuery("SELECT * FROM EMPLOYEES");
* CachedRowSetImpl crs = new CachedRowSetImpl();
* crs.populate(rs);
* </PRE>
* <P>
* The object <code>crs</code> now contains the data from the table
* <code>EMPLOYEES</code>, just as the object <code>rs</code> does.
* The difference is that the cursor for <code>crs</code> can be moved
* forward, backward, or to a particular row even if the cursor for
* <code>rs</code> can move only forward. In addition, <code>crs</code> is
* updatable even if <code>rs</code> is not because by default, a
* <code>CachedRowSet</code> object is both scrollable and updatable.
* <P>
* In summary, a <code>CachedRowSet</code> object can be thought of as simply
* a disconnected set of rows that are being cached outside of a data source.
* Being thin and serializable, it can easily be sent across a wire,
* and it is well suited to sending data to a thin client. However, a
* <code>CachedRowSet</code> object does have a limitation: It is limited in
* size by the amount of data it can store in memory at one time.
* <P>
* <h3>8.0 Getting Universal Data Access</h3>
* Another advantage of the <code>CachedRowSet</code> class is that it makes it
* possible to retrieve and store data from sources other than a relational
* database. The reader for a rowset can be implemented to read and populate
* its rowset with data from any tabular data source, including a spreadsheet
* or flat file.
* Because both a <code>CachedRowSet</code> object and its metadata can be
* created from scratch, a component that acts as a factory for rowsets
* can use this capability to create a rowset containing data from
* non-SQL data sources. Nevertheless, it is expected that most of the time,
* <code>CachedRowSet</code> objects will contain data that was fetched
* from an SQL database using the JDBC API.
* <P>
* <h3>9.0 Setting Properties</h3>
* All rowsets maintain a set of properties, which will usually be set using
* a tool. The number and kinds of properties a rowset has will vary,
* depending on what the rowset does and how it gets its data. For example,
* rowsets that get their data from a <code>ResultSet</code> object need to
* set the properties that are required for making a database connection.
* If a rowset uses the <code>DriverManager</code> facility to make a
* connection, it needs to set a property for the JDBC URL that identifies
* the appropriate driver, and it needs to set the properties that give the
* user name and password.
* If, on the other hand, the rowset uses a <code>DataSource</code> object
* to make the connection, which is the preferred method, it does not need to
* set the property for the JDBC URL. Instead, it needs to set
* properties for the logical name of the data source, for the user name,
* and for the password.
* <P>
* NOTE: In order to use a <code>DataSource</code> object for making a
* connection, the <code>DataSource</code> object must have been registered
* with a naming service that uses the Java Naming and Directory
* Interface<sup><font size=-2>TM</font></sup> (JNDI) API. This registration
* is usually done by a person acting in the capacity of a system
* administrator.
* <P>
* In order to be able to populate itself with data from a database, a rowset
* needs to set a command property. This property is a query that is a
* <code>PreparedStatement</code> object, which allows the query to have
* parameter placeholders that are set at run time, as opposed to design time.
* To set these placeholder parameters with values, a rowset provides
* setter methods for setting values of each data type,
* similar to the setter methods provided by the <code>PreparedStatement</code>
* interface.
* <P>
* The following code fragment illustrates how the <code>CachedRowSet</code>
* object <code>crs</code> might have its command property set. Note that if a
* tool is used to set properties, this is the code that the tool would use.
* <PRE>
* crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS " +
* "WHERE CREDIT_LIMIT > ? AND REGION = ?");
* </PRE>
* <P>
* The values that will be used to set the command's placeholder parameters are
* contained in the <code>RowSet</code> object's <code>params</code> field, which is a
* <code>Vector</code> object.
* The <code>CachedRowSet</code> class provides a set of setter
* methods for setting the elements in its <code>params</code> field. The
* following code fragment demonstrates setting the two parameters in the
* query from the previous example.
* <PRE>
* crs.setInt(1, 5000);
* crs.setString(2, "West");
* </PRE>
* <P>
* The <code>params</code> field now contains two elements, each of which is
* an array two elements long. The first element is the parameter number;
* the second is the value to be set.
* In this case, the first element of <code>params</code> is
* <code>1</code>, <code>5000</code>, and the second element is <code>2</code>,
* <code>"West"</code>. When an application calls the method
* <code>execute</code>, it will in turn call on this <code>RowSet</code> object's reader,
* which will in turn invoke its <code>readData</code> method. As part of
* its implementation, <code>readData</code> will get the values in
* <code>params</code> and use them to set the command's placeholder
* parameters.
* The following code fragment gives an idea of how the reader
* does this, after obtaining the <code>Connection</code> object
* <code>con</code>.
* <PRE>
* PreparedStatement pstmt = con.prepareStatement(crs.getCommand());
* reader.decodeParams();
* // decodeParams figures out which setter methods to use and does something
* // like the following:
* // for (i = 0; i < params.length; i++) {
* // pstmt.setObject(i + 1, params[i]);
* // }
* </PRE>
* <P>
* At this point, the command for <code>crs</code> is the query <code>"SELECT
* FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS WHERE CREDIT_LIMIT > 5000
* AND REGION = "West"</code>. After the <code>readData</code> method executes
* this command with the following line of code, it will have the data from
* <code>rs</code> with which to populate <code>crs</code>.
* <PRE>
* ResultSet rs = pstmt.executeQuery();
* </PRE>
* <P>
* The preceding code fragments give an idea of what goes on behind the
* scenes; they would not appear in an application, which would not invoke
* methods like <code>readData</code> and <code>decodeParams</code>.
* In contrast, the following code fragment shows what an application might do.
* It sets the rowset's command, sets the command's parameters, and executes
* the command. Simply by calling the <code>execute</code> method,
* <code>crs</code> populates itself with the requested data from the
* table <code>CUSTOMERS</code>.
* <PRE>
* crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
* "WHERE CREDIT_LIMIT > ? AND REGION = ?");
* crs.setInt(1, 5000);
* crs.setString(2, "West");
* crs.execute();
* </PRE>
*
* <h3>10.0 Paging Data</h3>
* Because a <code>CachedRowSet</code> object stores data in memory,
* the amount of data that it can contain at any one
* time is determined by the amount of memory available. To get around this limitation,
* a <code>CachedRowSet</code> object can retrieve data from a <code>ResultSet</code>
* object in chunks of data, called <i>pages</i>. To take advantage of this mechanism,
* an application sets the number of rows to be included in a page using the method
* <code>setPageSize</code>. In other words, if the page size is set to five, a chunk
* of five rows of
* data will be fetched from the data source at one time. An application can also
* optionally set the maximum number of rows that may be fetched at one time. If the
* maximum number of rows is set to zero, or no maximum number of rows is set, there is
* no limit to the number of rows that may be fetched at a time.
* <P>
* After properties have been set,
* the <code>CachedRowSet</code> object must be populated with data
* using either the method <code>populate</code> or the method <code>execute</code>.
* The following lines of code demonstrate using the method <code>populate</code>.
* Note that this version of the method takes two parameters, a <code>ResultSet</code>
* handle and the row in the <code>ResultSet</code> object from which to start
* retrieving rows.
* <PRE>
* CachedRowSet crs = new CachedRowSetImpl();
* crs.setMaxRows(20);
* crs.setPageSize(4);
* crs.populate(rsHandle, 10);
* </PRE>
* When this code runs, <i>crs</i> will be populated with four rows from
* <i>rsHandle</i> starting with the tenth row.
* <P>
* The next code fragment shows populating a <code>CachedRowSet</code> object using the
* method <code>execute</code>, which may or may not take a <code>Connection</code>
* object as a parameter. This code passes <code>execute</code> the <code>Connection</code>
* object <i>conHandle</i>.
* <P>
* Note that there are two differences between the following code
* fragment and the previous one. First, the method <code>setMaxRows</code> is not
* called, so there is no limit set for the number of rows that <i>crs</i> may contain.
* (Remember that <i>crs</i> always has the overriding limit of how much data it can
* store in memory.) The second difference is that the you cannot pass the method
* <code>execute</code> the number of the row in the <code>ResultSet</code> object
* from which to start retrieving rows. This method always starts with the first row.
* <PRE>
* CachedRowSet crs = new CachedRowSetImpl();
* crs.setPageSize(5);
* crs.execute(conHandle);
* </PRE>
* After this code has run, <i>crs</i> will contain five rows of data from the
* <code>ResultSet</code> object produced by the command for <i>crs</i>. The writer
* for <i>crs</i> will use <i>conHandle</i> to connect to the data source and
* execute the command for <i>crs</i>. An application is then able to operate on the
* data in <i>crs</i> in the same way that it would operate on data in any other
* <code>CachedRowSet</code> object.
* <P>
* To access the next page (chunk of data), an application calls the method
* <code>nextPage</code>. This method creates a new <code>CachedRowSet</code> object
* and fills it with the next page of data. For example, assume that the
* <code>CachedRowSet</code> object's command returns a <code>ResultSet</code> object
* <i>rs</i> with 1000 rows of data. If the page size has been set to 100, the first
* call to the method <code>nextPage</code> will create a <code>CachedRowSet</code> object
* containing the first 100 rows of <i>rs</i>. After doing what it needs to do with the
* data in these first 100 rows, the application can again call the method
* <code>nextPage</code> to create another <code>CachedRowSet</code> object
* with the second 100 rows from <i>rs</i>. The data from the first <code>CachedRowSet</code>
* object will no longer be in memory because it is replaced with the data from the
* second <code>CachedRowSet</code> object. After the tenth call to the method <code>nextPage</code>,
* the tenth <code>CachedRowSet</code> object will contain the last 100 rows of data from
* <i>rs</i>, which are stored in memory. At any given time, the data from only one
* <code>CachedRowSet</code> object is stored in memory.
* <P>
* The method <code>nextPage</code> returns <code>true</code> as long as the current
* page is not the last page of rows and <code>false</code> when there are no more pages.
* It can therefore be used in a <code>while</code> loop to retrieve all of the pages,
* as is demonstrated in the following lines of code.
* <PRE>
* CachedRowSet crs = CachedRowSetImpl();
* crs.setPageSize(100);
* crs.execute(conHandle);
*
* while(crs.nextPage()) {
* while(crs.next()) {
* . . . // operate on chunks (of 100 rows each) in crs,
* // row by row
* }
* }
* </PRE>
* After this code fragment has been run, the application will have traversed all
* 1000 rows, but it will have had no more than 100 rows in memory at a time.
* <P>
* The <code>CachedRowSet</code> interface also defines the method <code>previousPage</code>.
* Just as the method <code>nextPage</code> is analogous to the <code>ResultSet</code>
* method <code>next</code>, the method <code>previousPage</code> is analogous to
* the <code>ResultSet</code> method <code>previous</code>. Similar to the method
* <code>nextPage</code>, <code>previousPage</code> creates a <code>CachedRowSet</code>
* object containing the number of rows set as the page size. So, for instance, the
* method <code>previousPage</code> could be used in a <code>while</code> loop at
* the end of the preceding code fragment to navigate back through the pages from the last
* page to the first page.
* The method <code>previousPage</code> is also similar to <code>nextPage</code>
* in that it can be used in a <code>while</code>
* loop, except that it returns <code>true</code> as long as there is another page
* preceding it and <code>false</code> when there are no more pages ahead of it.
* <P>
* By positioning the cursor after the last row for each page,
* as is done in the following code fragment, the method <code>previous</code>
* navigates from the last row to the first row in each page.
* The code could also have left the cursor before the first row on each page and then
* used the method <code>next</code> in a <code>while</code> loop to navigate each page
* from the first row to the last row.
* <P>
* The following code fragment assumes a continuation from the previous code fragment,
* meaning that the cursor for the tenth <code>CachedRowSet</code> object is on the
* last row. The code moves the cursor to after the last row so that the first
* call to the method <code>previous</code> will put the cursor back on the last row.
* After going through all of the rows in the last page (the <code>CachedRowSet</code>
* object <i>crs</i>), the code then enters
* the <code>while</code> loop to get to the ninth page, go through the rows backwards,
* go to the eighth page, go through the rows backwards, and so on to the first row
* of the first page.
*
* <PRE>
* crs.afterLast();
* while(crs.previous()) {
* . . . // navigate through the rows, last to first
* {
* while(crs.previousPage()) {
* crs.afterLast();
* while(crs.previous()) {
* . . . // go from the last row to the first row of each page
* }
* }
* </PRE>
*
* @author Jonathan Bruce
*/
public interface CachedRowSet extends RowSet, Joinable {
/** {@collect.stats}
* Populates this <code>CachedRowSet</code> object with data from
* the given <code>ResultSet</code> object.
* <P>
* This method can be used as an alternative to the <code>execute</code> method when an
* application has a connection to an open <code>ResultSet</code> object.
* Using the method <code>populate</code> can be more efficient than using
* the version of the <code>execute</code> method that takes no parameters
* because it does not open a new connection and re-execute this
* <code>CachedRowSet</code> object's command. Using the <code>populate</code>
* method is more a matter of convenience when compared to using the version
* of <code>execute</code> that takes a <code>ResultSet</code> object.
*
* @param data the <code>ResultSet</code> object containing the data
* to be read into this <code>CachedRowSet</code> object
* @throws SQLException if a null <code>ResultSet</code> object is supplied
* or this <code>CachedRowSet</code> object cannot
* retrieve the associated <code>ResultSetMetaData</code> object
* @see #execute
* @see java.sql.ResultSet
* @see java.sql.ResultSetMetaData
*/
public void populate(ResultSet data) throws SQLException;
/** {@collect.stats}
* Populates this <code>CachedRowSet</code> object with data, using the
* given connection to produce the result set from which the data will be read.
* This method should close any database connections that it creates to
* ensure that this <code>CachedRowSet</code> object is disconnected except when
* it is reading data from its data source or writing data to its data source.
* <P>
* The reader for this <code>CachedRowSet</code> object
* will use <i>conn</i> to establish a connection to the data source
* so that it can execute the rowset's command and read data from the
* the resulting <code>ResultSet</code> object into this
* <code>CachedRowSet</code> object. This method also closes <i>conn</i>
* after it has populated this <code>CachedRowSet</code> object.
* <P>
* If this method is called when an implementation has already been
* populated, the contents and the metadata are (re)set. Also, if this method is
* called before the method <code>acceptChanges</code> has been called
* to commit outstanding updates, those updates are lost.
*
* @param conn a standard JDBC <code>Connection</code> object with valid
* properties
* @throws SQLException if an invalid <code>Connection</code> object is supplied
* or an error occurs in establishing the connection to the
* data source
* @see #populate
* @see java.sql.Connection
*/
public void execute(Connection conn) throws SQLException;
/** {@collect.stats}
* Propagates row update, insert and delete changes made to this
* <code>CachedRowSet</code> object to the underlying data source.
* <P>
* This method calls on this <code>CachedRowSet</code> object's writer
* to do the work behind the scenes.
* Standard <code>CachedRowSet</code> implementations should use the
* <code>SyncFactory</code> singleton
* to obtain a <code>SyncProvider</code> instance providing a
* <code>RowSetWriter</code> object (writer). The writer will attempt
* to propagate changes made in this <code>CachedRowSet</code> object
* back to the data source.
* <P>
* When the method <code>acceptChanges</code> executes successfully, in
* addition to writing changes to the data source, it
* makes the values in the current row be the values in the original row.
* <P>
* Depending on the synchronization level of the <code>SyncProvider</code>
* implementation being used, the writer will compare the original values
* with those in the data source to check for conflicts. When there is a conflict,
* the <code>RIOptimisticProvider</code> implementation, for example, throws a
* <code>SyncProviderException</code> and does not write anything to the
* data source.
* <P>
* An application may choose to catch the <code>SyncProviderException</code>
* object and retrieve the <code>SyncResolver</code> object it contains.
* The <code>SyncResolver</code> object lists the conflicts row by row and
* sets a lock on the data source to avoid further conflicts while the
* current conflicts are being resolved.
* Further, for each conflict, it provides methods for examining the conflict
* and setting the value that should be persisted in the data source.
* After all conflicts have been resolved, an application must call the
* <code>acceptChanges</code> method again to write resolved values to the
* data source. If all of the values in the data source are already the
* values to be persisted, the method <code>acceptChanges</code> does nothing.
* <P>
* Some provider implementations may use locks to ensure that there are no
* conflicts. In such cases, it is guaranteed that the writer will succeed in
* writing changes to the data source when the method <code>acceptChanges</code>
* is called. This method may be called immediately after the methods
* <code>updateRow</code>, <code>insertRow</code>, or <code>deleteRow</code>
* have been called, but it is more efficient to call it only once after
* all changes have been made so that only one connection needs to be
* established.
* <P>
* Note: The <code>acceptChanges()</code> method will determine if the
* <code>COMMIT_ON_ACCEPT_CHANGES</code> is set to true or not. If it is set
* to true, all updates in the synchronization are committed to the data
* source. Otherwise, the application <b>must</b> explicity call the
* <code>commit()</code> or <code>rollback()</code> methods as appropriate.
*
* @throws SQLException if the cursor is on the insert row
* @throws SyncProviderException if the underlying
* synchronization provider's writer fails to write the updates
* back to the data source
* @see #acceptChanges(java.sql.Connection)
* @see javax.sql.RowSetWriter
* @see javax.sql.rowset.spi.SyncFactory
* @see javax.sql.rowset.spi.SyncProvider
* @see javax.sql.rowset.spi.SyncProviderException
* @see javax.sql.rowset.spi.SyncResolver
*/
public void acceptChanges() throws SyncProviderException;
/** {@collect.stats}
* Propagates all row update, insert and delete changes to the
* data source backing this <code>CachedRowSet</code> object
* using the specified <code>Connection</code> object to establish a
* connection to the data source.
* <P>
* The other version of the <code>acceptChanges</code> method is not passed
* a connection because it uses
* the <code>Connection</code> object already defined within the <code>RowSet</code>
* object, which is the connection used for populating it initially.
* <P>
* This form of the method <code>acceptChanges</code> is similar to the
* form that takes no arguments; however, unlike the other form, this form
* can be used only when the underlying data source is a JDBC data source.
* The updated <code>Connection</code> properties must be used by the
* <code>SyncProvider</code> to reset the <code>RowSetWriter</code>
* configuration to ensure that the contents of the <code>CachedRowSet</code>
* object are synchronized correctly.
* <P>
* When the method <code>acceptChanges</code> executes successfully, in
* addition to writing changes to the data source, it
* makes the values in the current row be the values in the original row.
* <P>
* Depending on the synchronization level of the <code>SyncProvider</code>
* implementation being used, the writer will compare the original values
* with those in the data source to check for conflicts. When there is a conflict,
* the <code>RIOptimisticProvider</code> implementation, for example, throws a
* <code>SyncProviderException</code> and does not write anything to the
* data source.
* <P>
* An application may choose to catch the <code>SyncProviderException</code>
* object and retrieve the <code>SyncResolver</code> object it contains.
* The <code>SyncResolver</code> object lists the conflicts row by row and
* sets a lock on the data source to avoid further conflicts while the
* current conflicts are being resolved.
* Further, for each conflict, it provides methods for examining the conflict
* and setting the value that should be persisted in the data source.
* After all conflicts have been resolved, an application must call the
* <code>acceptChanges</code> method again to write resolved values to the
* data source. If all of the values in the data source are already the
* values to be persisted, the method <code>acceptChanges</code> does nothing.
* <P>
* Some provider implementations may use locks to ensure that there are no
* conflicts. In such cases, it is guaranteed that the writer will succeed in
* writing changes to the data source when the method <code>acceptChanges</code>
* is called. This method may be called immediately after the methods
* <code>updateRow</code>, <code>insertRow</code>, or <code>deleteRow</code>
* have been called, but it is more efficient to call it only once after
* all changes have been made so that only one connection needs to be
* established.
* <P>
* Note: The <code>acceptChanges()</code> method will determine if the
* <code>COMMIT_ON_ACCEPT_CHANGES</code> is set to true or not. If it is set
* to true, all updates in the synchronization are committed to the data
* source. Otherwise, the application <b>must</b> explicity call the
* <code>commit</code> or <code>rollback</code> methods as appropriate.
*
* @param con a standard JDBC <code>Connection</code> object
* @throws SQLException if the cursor is on the insert row
* @throws SyncProviderException if the underlying
* synchronization provider's writer fails to write the updates
* back to the data source
* @see #acceptChanges()
* @see javax.sql.RowSetWriter
* @see javax.sql.rowset.spi.SyncFactory
* @see javax.sql.rowset.spi.SyncProvider
* @see javax.sql.rowset.spi.SyncProviderException
* @see javax.sql.rowset.spi.SyncResolver
*/
public void acceptChanges(Connection con) throws SyncProviderException;
/** {@collect.stats}
* Restores this <code>CachedRowSet</code> object to its original
* value, that is, its value before the last set of changes. If there
* have been no changes to the rowset or only one set of changes,
* the original value is the value with which this <code>CachedRowSet</code> object
* was populated; otherwise, the original value is
* the value it had immediately before its current value.
* <P>
* When this method is called, a <code>CachedRowSet</code> implementation
* must ensure that all updates, inserts, and deletes to the current
* rowset instance are replaced by the previous values. In addition,
* the cursor should be
* reset to the first row and a <code>rowSetChanged</code> event
* should be fired to notify all registered listeners.
*
* @throws SQLException if an error occurs rolling back the current value of
* this <code>CachedRowSet</code> object to its previous value
* @see javax.sql.RowSetListener#rowSetChanged
*/
public void restoreOriginal() throws SQLException;
/** {@collect.stats}
* Releases the current contents of this <code>CachedRowSet</code>
* object and sends a <code>rowSetChanged</code> event to all
* registered listeners. Any outstanding updates are discarded and
* the rowset contains no rows after this method is called. There
* are no interactions with the underlying data source, and any rowset
* content, metadata, and content updates should be non-recoverable.
* <P>
* This <code>CachedRowSet</code> object should lock until its contents and
* associated updates are fully cleared, thus preventing 'dirty' reads by
* other components that hold a reference to this <code>RowSet</code> object.
* In addition, the contents cannot be released
* until all all components reading this <code>CachedRowSet</code> object
* have completed their reads. This <code>CachedRowSet</code> object
* should be returned to normal behavior after firing the
* <code>rowSetChanged</code> event.
* <P>
* The metadata, including JDBC properties and Synchronization SPI
* properties, are maintained for future use. It is important that
* properties such as the <code>command</code> property be
* relevant to the originating data source from which this <code>CachedRowSet</code>
* object was originally established.
* <P>
* This method empties a rowset, as opposed to the <code>close</code> method,
* which marks the entire rowset as recoverable to allow the garbage collector
* the rowset's Java VM resources.
*
* @throws SQLException if an error occurs flushing the contents of this
* <code>CachedRowSet</code> object
* @see javax.sql.RowSetListener#rowSetChanged
* @see java.sql.ResultSet#close
*/
public void release() throws SQLException;
/** {@collect.stats}
* Cancels the deletion of the current row and notifies listeners that
* a row has changed. After this method is called, the current row is
* no longer marked for deletion. This method can be called at any
* time during the lifetime of the rowset.
* <P>
* In addition, multiple cancellations of row deletions can be made
* by adjusting the position of the cursor using any of the cursor
* position control methods such as:
* <ul>
* <li><code>CachedRowSet.absolute</code>
* <li><code>CachedRowSet.first</code>
* <li><code>CachedRowSet.last</code>
* </ul>
*
* @throws SQLException if (1) the current row has not been deleted or
* (2) the cursor is on the insert row, before the first row, or
* after the last row
* @see javax.sql.rowset.CachedRowSet#undoInsert
* @see java.sql.ResultSet#cancelRowUpdates
*/
public void undoDelete() throws SQLException;
/** {@collect.stats}
* Immediately removes the current row from this <code>CachedRowSet</code>
* object if the row has been inserted, and also notifies listeners that a
* row has changed. This method can be called at any time during the
* lifetime of a rowset and assuming the current row is within
* the exception limitations (see below), it cancels the row insertion
* of the current row.
* <P>
* In addition, multiple cancellations of row insertions can be made
* by adjusting the position of the cursor using any of the cursor
* position control methods such as:
* <ul>
* <li><code>CachedRowSet.absolute</code>
* <li><code>CachedRowSet.first</code>
* <li><code>CachedRowSet.last</code>
* </ul>
*
* @throws SQLException if (1) the current row has not been inserted or (2)
* the cursor is before the first row, after the last row, or on the
* insert row
* @see javax.sql.rowset.CachedRowSet#undoDelete
* @see java.sql.ResultSet#cancelRowUpdates
*/
public void undoInsert() throws SQLException;
/** {@collect.stats}
* Immediately reverses the last update operation if the
* row has been modified. This method can be
* called to reverse updates on all columns until all updates in a row have
* been rolled back to their state just prior to the last synchronization
* (<code>acceptChanges</code>) or population. This method may also be called
* while performing updates to the insert row.
* <P>
* <code>undoUpdate</code> may be called at any time during the lifetime of a
* rowset; however, after a synchronization has occurred, this method has no
* effect until further modification to the rowset data has occurred.
*
* @throws SQLException if the cursor is before the first row or after the last
* row in in this <code>CachedRowSet</code> object
* @see #undoDelete
* @see #undoInsert
* @see java.sql.ResultSet#cancelRowUpdates
*/
public void undoUpdate() throws SQLException;
/** {@collect.stats}
* Indicates whether the designated column in the current row of this
* <code>CachedRowSet</code> object has been updated.
*
* @param idx an <code>int</code> identifying the column to be checked for updates
* @return <code>true</code> if the designated column has been visibly updated;
* <code>false</code> otherwise
* @throws SQLException if the cursor is on the insert row, before the first row,
* or after the last row
* @see java.sql.DatabaseMetaData#updatesAreDetected
*/
public boolean columnUpdated(int idx) throws SQLException;
/** {@collect.stats}
* Indicates whether the designated column in the current row of this
* <code>CachedRowSet</code> object has been updated.
*
* @param columnName a <code>String</code> object giving the name of the
* column to be checked for updates
* @return <code>true</code> if the column has been visibly updated;
* <code>false</code> otherwise
* @throws SQLException if the cursor is on the insert row, before the first row,
* or after the last row
* @see java.sql.DatabaseMetaData#updatesAreDetected
*/
public boolean columnUpdated(String columnName) throws SQLException;
/** {@collect.stats}
* Converts this <code>CachedRowSet</code> object to a <code>Collection</code>
* object that contains all of this <code>CachedRowSet</code> object's data.
* Implementations have some latitude in
* how they can represent this <code>Collection</code> object because of the
* abstract nature of the <code>Collection</code> framework.
* Each row must be fully represented in either a
* general purpose <code>Collection</code> implementation or a specialized
* <code>Collection</code> implementation, such as a <code>TreeMap</code>
* object or a <code>Vector</code> object.
* An SQL <code>NULL</code> column value must be represented as a <code>null</code>
* in the Java programming language.
* <P>
* The standard reference implementation for the <code>CachedRowSet</code>
* interface uses a <code>TreeMap</code> object for the rowset, with the
* values in each row being contained in <code>Vector</code> objects. It is
* expected that most implementations will do the same.
* <P>
* The <code>TreeMap</code> type of collection guarantees that the map will be in
* ascending key order, sorted according to the natural order for the
* key's class.
* Each key references a <code>Vector</code> object that corresponds to one
* row of a <code>RowSet</code> object. Therefore, the size of each
* <code>Vector</code> object must be exactly equal to the number of
* columns in the <code>RowSet</code> object.
* The key used by the <code>TreeMap</code> collection is determined by the
* implementation, which may choose to leverage a set key that is
* available within the internal <code>RowSet</code> tabular structure by
* virtue of a key already set either on the <code>RowSet</code> object
* itself or on the underlying SQL data.
* <P>
*
* @return a <code>Collection</code> object that contains the values in
* each row in this <code>CachedRowSet</code> object
* @throws SQLException if an error occurs generating the collection
* @see #toCollection(int)
* @see #toCollection(String)
*/
public Collection<?> toCollection() throws SQLException;
/** {@collect.stats}
* Converts the designated column in this <code>CachedRowSet</code> object
* to a <code>Collection</code> object. Implementations have some latitude in
* how they can represent this <code>Collection</code> object because of the
* abstract nature of the <code>Collection</code> framework.
* Each column value should be fully represented in either a
* general purpose <code>Collection</code> implementation or a specialized
* <code>Collection</code> implementation, such as a <code>Vector</code> object.
* An SQL <code>NULL</code> column value must be represented as a <code>null</code>
* in the Java programming language.
* <P>
* The standard reference implementation uses a <code>Vector</code> object
* to contain the column values, and it is expected
* that most implementations will do the same. If a <code>Vector</code> object
* is used, it size must be exactly equal to the number of rows
* in this <code>CachedRowSet</code> object.
*
* @param column an <code>int</code> indicating the column whose values
* are to be represented in a <code>Collection</code> object
* @return a <code>Collection</code> object that contains the values
* stored in the specified column of this <code>CachedRowSet</code>
* object
* @throws SQLException if an error occurs generating the collection or
* an invalid column id is provided
* @see #toCollection
* @see #toCollection(String)
*/
public Collection<?> toCollection(int column) throws SQLException;
/** {@collect.stats}
* Converts the designated column in this <code>CachedRowSet</code> object
* to a <code>Collection</code> object. Implementations have some latitude in
* how they can represent this <code>Collection</code> object because of the
* abstract nature of the <code>Collection</code> framework.
* Each column value should be fully represented in either a
* general purpose <code>Collection</code> implementation or a specialized
* <code>Collection</code> implementation, such as a <code>Vector</code> object.
* An SQL <code>NULL</code> column value must be represented as a <code>null</code>
* in the Java programming language.
* <P>
* The standard reference implementation uses a <code>Vector</code> object
* to contain the column values, and it is expected
* that most implementations will do the same. If a <code>Vector</code> object
* is used, it size must be exactly equal to the number of rows
* in this <code>CachedRowSet</code> object.
*
* @param column a <code>String</code> object giving the name of the
* column whose values are to be represented in a collection
* @return a <code>Collection</code> object that contains the values
* stored in the specified column of this <code>CachedRowSet</code>
* object
* @throws SQLException if an error occurs generating the collection or
* an invalid column id is provided
* @see #toCollection
* @see #toCollection(int)
*/
public Collection<?> toCollection(String column) throws SQLException;
/** {@collect.stats}
* Retrieves the <code>SyncProvider</code> implementation for this
* <code>CachedRowSet</code> object. Internally, this method is used by a rowset
* to trigger read or write actions between the rowset
* and the data source. For example, a rowset may need to get a handle
* on the the rowset reader (<code>RowSetReader</code> object) from the
* <code>SyncProvider</code> to allow the rowset to be populated.
* <pre>
* RowSetReader rowsetReader = null;
* SyncProvider provider =
* SyncFactory.getInstance("javax.sql.rowset.provider.RIOptimisticProvider");
* if (provider instanceof RIOptimisticProvider) {
* rowsetReader = provider.getRowSetReader();
* }
* </pre>
* Assuming <i>rowsetReader</i> is a private, accessible field within
* the rowset implementation, when an application calls the <code>execute</code>
* method, it in turn calls on the reader's <code>readData</code> method
* to populate the <code>RowSet</code> object.
*<pre>
* rowsetReader.readData((RowSetInternal)this);
* </pre>
* <P>
* In addition, an application can use the <code>SyncProvider</code> object
* returned by this method to call methods that return information about the
* <code>SyncProvider</code> object, including information about the
* vendor, version, provider identification, synchronization grade, and locks
* it currently has set.
*
* @return the <code>SyncProvider</code> object that was set when the rowset
* was instantiated, or if none was was set, the default provider
* @throws SQLException if an error occurs while returning the
* <code>SyncProvider</code> object
* @see #setSyncProvider
*/
public SyncProvider getSyncProvider() throws SQLException;
/** {@collect.stats}
* Sets the <code>SyncProvider</code> objec for this <code>CachedRowSet</code>
* object to the one specified. This method
* allows the <code>SyncProvider</code> object to be reset.
* <P>
* A <code>CachedRowSet</code> implementation should always be instantiated
* with an available <code>SyncProvider</code> mechanism, but there are
* cases where resetting the <code>SyncProvider</code> object is desirable
* or necessary. For example, an application might want to use the default
* <code>SyncProvider</code> object for a time and then choose to use a provider
* that has more recently become available and better fits its needs.
* <P>
* Resetting the <code>SyncProvider</code> object causes the
* <code>RowSet</code> object to request a new <code>SyncProvider</code> implementation
* from the <code>SyncFactory</code>. This has the effect of resetting
* all previous connections and relationships with the originating
* data source and can potentially drastically change the synchronization
* behavior of a disconnected rowset.
*
* @param provider a <code>String</code> object giving the fully qualified class
* name of a <code>SyncProvider</code> implementation
* @throws SQLException if an error occurs while attempting to reset the
* <code>SyncProvider</code> implementation
* @see #getSyncProvider
*/
public void setSyncProvider(String provider) throws SQLException;
/** {@collect.stats}
* Returns the number of rows in this <code>CachedRowSet</code>
* object.
*
* @return number of rows in the rowset
*/
public int size();
/** {@collect.stats}
* Sets the metadata for this <code>CachedRowSet</code> object with
* the given <code>RowSetMetaData</code> object. When a
* <code>RowSetReader</code> object is reading the contents of a rowset,
* it creates a <code>RowSetMetaData</code> object and initializes
* it using the methods in the <code>RowSetMetaData</code> implementation.
* The reference implementation uses the <code>RowSetMetaDataImpl</code>
* class. When the reader has completed reading the rowset contents,
* this method is called internally to pass the <code>RowSetMetaData</code>
* object to the rowset.
*
* @param md a <code>RowSetMetaData</code> object containing
* metadata about the columns in this <code>CachedRowSet</code> object
* @throws SQLException if invalid metadata is supplied to the
* rowset
*/
public void setMetaData(RowSetMetaData md) throws SQLException;
/** {@collect.stats}
* Returns a <code>ResultSet</code> object containing the original value of this
* <code>CachedRowSet</code> object.
* <P>
* The cursor for the <code>ResultSet</code>
* object should be positioned before the first row.
* In addition, the returned <code>ResultSet</code> object should have the following
* properties:
* <UL>
* <LI>ResultSet.TYPE_SCROLL_INSENSITIVE
* <LI>ResultSet.CONCUR_UPDATABLE
* </UL>
* <P>
* The original value for a <code>RowSet</code> object is the value it had before
* the last synchronization with the underlying data source. If there have been
* no synchronizations, the original value will be the value with which the
* <code>RowSet</code> object was populated. This method is called internally
* when an aplication calls the method <code>acceptChanges</code> and the
* <code>SyncProvider</code> object has been implemented to check for conflicts.
* If this is the case, the writer compares the original value with the value
* currently in the data source to check for conflicts.
*
* @return a <code>ResultSet</code> object that contains the original value for
* this <code>CachedRowSet</code> object
* @throws SQLException if an error occurs producing the
* <code>ResultSet</code> object
*/
public ResultSet getOriginal() throws SQLException;
/** {@collect.stats}
* Returns a <code>ResultSet</code> object containing the original value for the
* current row only of this <code>CachedRowSet</code> object.
* <P>
* The cursor for the <code>ResultSet</code>
* object should be positioned before the first row.
* In addition, the returned <code>ResultSet</code> object should have the following
* properties:
* <UL>
* <LI>ResultSet.TYPE_SCROLL_INSENSITIVE
* <LI>ResultSet.CONCUR_UPDATABLE
* </UL>
*
* @return the original result set of the row
* @throws SQLException if there is no current row
* @see #setOriginalRow
*/
public ResultSet getOriginalRow() throws SQLException;
/** {@collect.stats}
* Sets the current row in this <code>CachedRowSet</code> object as the original
* row.
* <P>
* This method is called internally after the any modified values in the current
* row have been synchronized with the data source. The current row must be tagged
* as no longer inserted, deleted or updated.
* <P>
* A call to <code>setOriginalRow</code> is irreversible.
*
* @throws SQLException if there is no current row or an error is
* encountered resetting the contents of the original row
* @see #getOriginalRow
*/
public void setOriginalRow() throws SQLException;
/** {@collect.stats}
* Returns an identifier for the object (table) that was used to
* create this <code>CachedRowSet</code> object. This name may be set on multiple occasions,
* and the specification imposes no limits on how many times this
* may occur or whether standard implementations should keep track
* of previous table names.
*
* @return a <code>String</code> object giving the name of the table that is the
* source of data for this <code>CachedRowSet</code> object or <code>null</code>
* if no name has been set for the table
* @throws SQLException if an error is encountered returning the table name
* @see javax.sql.RowSetMetaData#getTableName
*/
public String getTableName() throws SQLException;
/** {@collect.stats}
* Sets the identifier for the table from which this <code>CachedRowSet</code>
* object was derived to the given table name. The writer uses this name to
* determine which table to use when comparing the values in the data source with the
* <code>CachedRowSet</code> object's values during a synchronization attempt.
* The table identifier also indicates where modified values from this
* <code>CachedRowSet</code> object should be written.
* <P>
* The implementation of this <code>CachedRowSet</code> object may obtain the
* the name internally from the <code>RowSetMetaDataImpl</code> object.
*
* @param tabName a <code>String</code> object identifying the table from which this
<code>CachedRowSet</code> object was derived; cannot be <code>null</code>
* but may be an empty string
* @throws SQLException if an error is encountered naming the table or
* <i>tabName</i> is <code>null</code>
* @see javax.sql.RowSetMetaData#setTableName
* @see javax.sql.RowSetWriter
* @see javax.sql.rowset.spi.SyncProvider
*/
public void setTableName(String tabName) throws SQLException;
/** {@collect.stats}
* Returns an array containing one or more column numbers indicating the columns
* that form a key that uniquely
* identifies a row in this <code>CachedRowSet</code> object.
*
* @return an array containing the column number or numbers that indicate which columns
* constitute a primary key
* for a row in this <code>CachedRowSet</code> object. This array should be
* empty if no columns are representative of a primary key.
* @throws SQLException if this <code>CachedRowSet</code> object is empty
* @see #setKeyColumns
* @see Joinable#getMatchColumnIndexes
* @see Joinable#getMatchColumnNames
*/
public int[] getKeyColumns() throws SQLException;
/** {@collect.stats}
* Sets this <code>CachedRowSet</code> object's <code>keyCols</code>
* field with the given array of column numbers, which forms a key
* for uniquely identifying a row in this <code>CachedRowSet</code> object.
* <p>
* If a <code>CachedRowSet</code> object becomes part of a <code>JoinRowSet</code>
* object, the keys defined by this method and the resulting constraints are
* maintained if the columns designated as key columns also become match
* columns.
*
* @param keys an array of <code>int</code> indicating the columns that form
* a primary key for this <code>CachedRowSet</code> object; every
* element in the array must be greater than <code>0</code> and
* less than or equal to the number of columns in this rowset
* @throws SQLException if any of the numbers in the given array
* are not valid for this rowset
* @see #getKeyColumns
* @see Joinable#setMatchColumn(String)
* @see Joinable#setMatchColumn(int)
*/
public void setKeyColumns(int[] keys) throws SQLException;
/** {@collect.stats}
* Returns a new <code>RowSet</code> object backed by the same data as
* that of this <code>CachedRowSet</code> object. In effect, both
* <code>CachedRowSet</code> objects have a cursor over the same data.
* As a result, any changes made by a duplicate are visible to the original
* and to any other duplicates, just as a change made by the original is visible
* to all of its duplicates. If a duplicate calls a method that changes the
* underlying data, the method it calls notifies all registered listeners
* just as it would when it is called by the original <code>CachedRowSet</code>
* object.
* <P>
* In addition, any <code>RowSet</code> object
* created by this method will have the same properties as this
* <code>CachedRowSet</code> object. For example, if this <code>CachedRowSet</code>
* object is read-only, all of its duplicates will also be read-only. If it is
* changed to be updatable, the duplicates also become updatable.
* <P>
* NOTE: If multiple threads access <code>RowSet</code> objects created from
* the <code>createShared()</code> method, the following behavior is specified
* to preserve shared data integrity: reads and writes of all
* shared <code>RowSet</code> objects should be made serially between each
* object and the single underlying tabular structure.
*
* @return a new shared <code>RowSet</code> object that has the same properties
* as this <code>CachedRowSet</code> object and that has a cursor over
* the same data
* @throws SQLException if an error occurs or cloning is not
* supported in the underlying platform
* @see javax.sql.RowSetEvent
* @see javax.sql.RowSetListener
*/
public RowSet createShared() throws SQLException;
/** {@collect.stats}
* Creates a <code>RowSet</code> object that is a deep copy of the data in
* this <code>CachedRowSet</code> object. In contrast to
* the <code>RowSet</code> object generated from a <code>createShared</code>
* call, updates made to the copy of the original <code>RowSet</code> object
* must not be visible to the original <code>RowSet</code> object. Also, any
* event listeners that are registered with the original
* <code>RowSet</code> must not have scope over the new
* <code>RowSet</code> copies. In addition, any constraint restrictions
* established must be maintained.
*
* @return a new <code>RowSet</code> object that is a deep copy
* of this <code>CachedRowSet</code> object and is
* completely independent of this <code>CachedRowSet</code> object
* @throws SQLException if an error occurs in generating the copy of
* the of this <code>CachedRowSet</code> object
* @see #createShared
* @see #createCopySchema
* @see #createCopyNoConstraints
* @see javax.sql.RowSetEvent
* @see javax.sql.RowSetListener
*/
public CachedRowSet createCopy() throws SQLException;
/** {@collect.stats}
* Creates a <code>CachedRowSet</code> object that is an empty copy of this
* <code>CachedRowSet</code> object. The copy
* must not contain any contents but only represent the table
* structure of the original <code>CachedRowSet</code> object. In addition, primary
* or foreign key constraints set in the originating <code>CachedRowSet</code> object must
* be equally enforced in the new empty <code>CachedRowSet</code> object.
* In contrast to
* the <code>RowSet</code> object generated from a <code>createShared</code> method
* call, updates made to a copy of this <code>CachedRowSet</code> object with the
* <code>createCopySchema</code> method must not be visible to it.
* <P>
* Applications can form a <code>WebRowSet</code> object from the <code>CachedRowSet</code>
* object returned by this method in order
* to export the <code>RowSet</code> schema definition to XML for future use.
*
* @throws SQLException if an error occurs in cloning the structure of this
* <code>CachedRowSet</code> object
* @see #createShared
* @see #createCopySchema
* @see #createCopyNoConstraints
* @see javax.sql.RowSetEvent
* @see javax.sql.RowSetListener
*/
public CachedRowSet createCopySchema() throws SQLException;
/** {@collect.stats}
* Creates a <code>CachedRowSet</code> object that is a deep copy of
* this <code>CachedRowSet</code> object's data but is independent of it.
* In contrast to
* the <code>RowSet</code> object generated from a <code>createShared</code>
* method call, updates made to a copy of this <code>CachedRowSet</code> object
* must not be visible to it. Also, any
* event listeners that are registered with this
* <code>CachedRowSet</code> object must not have scope over the new
* <code>RowSet</code> object. In addition, any constraint restrictions
* established for this <code>CachedRowSet</code> object must <b>not</b> be maintained
* in the copy.
*
* @return a new <code>CachedRowSet</code> object that is a deep copy
* of this <code>CachedRowSet</code> object and is
* completely independent of this <code>CachedRowSet</code> object
* @throws SQLException if an error occurs in generating the copy of
* the of this <code>CachedRowSet</code> object
* @see #createCopy
* @see #createShared
* @see #createCopySchema
* @see javax.sql.RowSetEvent
* @see javax.sql.RowSetListener
*/
public CachedRowSet createCopyNoConstraints() throws SQLException;
/** {@collect.stats}
* Retrieves the first warning reported by calls on this <code>RowSet</code> object.
* Subsequent warnings on this <code>RowSet</code> object will be chained to the
* <code>RowSetWarning</code> object that this method returns.
*
* The warning chain is automatically cleared each time a new row is read.
* This method may not be called on a RowSet object that has been closed;
* doing so will cause a <code>SQLException</code> to be thrown.
*
* @return RowSetWarning the first <code>RowSetWarning</code>
* object reported or null if there are none
* @throws SQLException if this method is called on a closed RowSet
* @see RowSetWarning
*/
public RowSetWarning getRowSetWarnings() throws SQLException;
/** {@collect.stats}
* Retrieves a <code>boolean</code> indicating whether rows marked
* for deletion appear in the set of current rows. If <code>true</code> is
* returned, deleted rows are visible with the current rows. If
* <code>false</code> is returned, rows are not visible with the set of
* current rows. The default value is <code>false</code>.
* <P>
* Standard rowset implementations may choose to restrict this behavior
* due to security considerations or to better fit certain deployment
* scenarios. This is left as implementation defined and does not
* represent standard behavior.
* <P>
* Note: Allowing deleted rows to remain visible complicates the behavior
* of some standard JDBC <code>RowSet</code> Implementations methods.
* However, most rowset users can simply ignore this extra detail because
* only very specialized applications will likely want to take advantage of
* this feature.
*
* @return <code>true</code> if deleted rows are visible;
* <code>false</code> otherwise
* @throws SQLException if a rowset implementation is unable to
* to determine whether rows marked for deletion are visible
* @see #setShowDeleted
*/
public boolean getShowDeleted() throws SQLException;
/** {@collect.stats}
* Sets the property <code>showDeleted</code> to the given
* <code>boolean</code> value, which determines whether
* rows marked for deletion appear in the set of current rows.
* If the value is set to <code>true</code>, deleted rows are immediately
* visible with the set of current rows. If the value is set to
* <code>false</code>, the deleted rows are set as invisible with the
* current set of rows.
* <P>
* Standard rowset implementations may choose to restrict this behavior
* due to security considerations or to better fit certain deployment
* scenarios. This is left as implementations defined and does not
* represent standard behavior.
*
* @param b <code>true</code> if deleted rows should be shown;
* <code>false</code> otherwise
* @exception SQLException if a rowset implementation is unable to
* to reset whether deleted rows should be visible
* @see #getShowDeleted
*/
public void setShowDeleted(boolean b) throws SQLException;
/** {@collect.stats}
* Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
* a <code>Connection</code> object from the <code>ResultSet</code> or JDBC
* properties passed to it's constructors. This method wraps the
* <code>Connection</code> commit method to allow flexible
* auto commit or non auto commit transactional control support.
* <p>
* Makes all changes that are performed by the <code>acceptChanges()</code>
* method since the previous commit/rollback permanent. This method should
* be used only when auto-commit mode has been disabled.
*
* @throws SQLException if a database access error occurs or this
* Connection object within this <code>CachedRowSet</code> is in auto-commit mode
* @see java.sql.Connection#setAutoCommit
*/
public void commit() throws SQLException;
/** {@collect.stats}
* Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
* a <code>Connection</code> object from the original <code>ResultSet</code>
* or JDBC properties passed to it.
* <p>
* Undoes all changes made in the current transaction. This method
* should be used only when auto-commit mode has been disabled.
*
* @throws SQLException if a database access error occurs or this Connection
* object within this <code>CachedRowSet</code> is in auto-commit mode.
*/
public void rollback() throws SQLException;
/** {@collect.stats}
* Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
* a <code>Connection</code> object from the original <code>ResultSet</code>
* or JDBC properties passed to it.
* <p>
* Undoes all changes made in the current transaction back to the last
* <code>Savepoint</code> transaction marker. This method should be used only
* when auto-commit mode has been disabled.
*
* @param s A <code>Savepoint</code> transaction marker
* @throws SQLException if a database access error occurs or this Connection
* object within this <code>CachedRowSet</code> is in auto-commit mode.
*/
public void rollback(Savepoint s) throws SQLException;
/** {@collect.stats}
* Causes the <code>CachedRowSet</code> object's <code>SyncProvider</code>
* to commit the changes when <code>acceptChanges()</code> is called. If
* set to false, the changes will <b>not</b> be committed until one of the
* <code>CachedRowSet</code> interface transaction methods is called.
*
* @see #commit
* @see #rollback
*/
public static final boolean COMMIT_ON_ACCEPT_CHANGES = true;
/** {@collect.stats}
* Notifies registered listeners that a RowSet object in the given RowSetEvent
* object has populated a number of additional rows. The <code>numRows</code> parameter
* ensures that this event will only be fired every <code>numRow</code>.
* <p>
* The source of the event can be retrieved with the method event.getSource.
*
* @param event a <code>RowSetEvent</code> object that contains the
* <code>RowSet</code> object that is the source of the events
* @param numRows when populating, the number of rows interval on which the
* <code>CachedRowSet</code> populated should fire; the default value
* is zero; cannot be less than <code>fetchSize</code> or zero
*/
public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException;
/** {@collect.stats}
* Populates this <code>CachedRowSet</code> object with data from
* the given <code>ResultSet</code> object. While related to the <code>populate(ResultSet)</code>
* method, an additional parameter is provided to allow starting position within
* the <code>ResultSet</code> from where to populate the CachedRowSet
* instance.
* <P>
* This method can be used as an alternative to the <code>execute</code> method when an
* application has a connection to an open <code>ResultSet</code> object.
* Using the method <code>populate</code> can be more efficient than using
* the version of the <code>execute</code> method that takes no parameters
* because it does not open a new connection and re-execute this
* <code>CachedRowSet</code> object's command. Using the <code>populate</code>
* method is more a matter of convenience when compared to using the version
* of <code>execute</code> that takes a <code>ResultSet</code> object.
*
* @param startRow the position in the <code>ResultSet</code> from where to start
* populating the records in this <code>CachedRowSet</code>
* @param rs the <code>ResultSet</code> object containing the data
* to be read into this <code>CachedRowSet</code> object
* @throws SQLException if a null <code>ResultSet</code> object is supplied
* or this <code>CachedRowSet</code> object cannot
* retrieve the associated <code>ResultSetMetaData</code> object
* @see #execute
* @see #populate(ResultSet)
* @see java.sql.ResultSet
* @see java.sql.ResultSetMetaData
*/
public void populate(ResultSet rs, int startRow) throws SQLException;
/** {@collect.stats}
* Sets the <code>CachedRowSet</code> object's page-size. A <code>CachedRowSet</code>
* may be configured to populate itself in page-size sized batches of rows. When
* either <code>populate()</code> or <code>execute()</code> are called, the
* <code>CachedRowSet</code> fetches an additional page according to the
* original SQL query used to populate the RowSet.
*
* @param size the page-size of the <code>CachedRowSet</code>
* @throws SQLException if an error occurs setting the <code>CachedRowSet</code>
* page size or if the page size is less than 0.
*/
public void setPageSize(int size) throws SQLException;
/** {@collect.stats}
* Returns the page-size for the <code>CachedRowSet</code> object
*
* @return an <code>int</code> page size
*/
public int getPageSize();
/** {@collect.stats}
* Increments the current page of the <code>CachedRowSet</code>. This causes
* the <code>CachedRowSet</code> implementation to fetch the next page-size
* rows and populate the RowSet, if remaining rows remain within scope of the
* original SQL query used to populated the RowSet.
*
* @return true if more pages exist; false if this is the last page
* @throws SQLException if an error occurs fetching the next page, or if this
* method is called prematurely before populate or execute.
*/
public boolean nextPage() throws SQLException;
/** {@collect.stats}
* Decrements the current page of the <code>CachedRowSet</code>. This causes
* the <code>CachedRowSet</code> implementation to fetch the previous page-size
* rows and populate the RowSet. The amount of rows returned in the previous
* page must always remain within scope of the original SQL query used to
* populate the RowSet.
*
* @return true if the previous page is successfully retrieved; false if this
* is the first page.
* @throws SQLException if an error occurs fetching the previous page, or if
* this method is called prematurely before populate or execute.
*/
public boolean previousPage() throws SQLException;
}
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.