home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
jfc.bin
/
DocumentEvent.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
4KB
|
138 lines
/*
* @(#)DocumentEvent.java 1.12 98/01/14
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing.event;
import com.sun.java.swing.undo.*;
import com.sun.java.swing.text.*;
/**
* Interface for document change notifications.
*
* @author Timothy Prinzing
* @version 1.12 01/14/98
*/
public interface DocumentEvent {
/**
* Returns the offset within the document of the start
* of the change.
*
* @return the offset
*/
public int getOffset();
/**
* Returns the length of the change.
*
* @return the length
*/
public int getLength();
/**
* Gets the document that sourced the change event.
*
* @returns the document
*/
public Document getDocument();
/**
* Gets the type of event.
*/
public EventType getType();
/**
* Gets the change information for the given element.
* The change information describes what elements were
* added and removed and the location. If there were
* no changes, null is returned.
*
* @param elem the element
* @return the change information, or null if the
* element was not modified
*/
public ElementChange getChange(Element elem);
/**
* Typesafe enumeration for document event types
*/
public static final class EventType {
private EventType(String s) {
typeString = s;
}
public static final EventType INSERT = new EventType("INSERT");
public static final EventType REMOVE = new EventType("REMOVE");
public static final EventType CHANGE = new EventType("CHANGE");
public String toString() {
return typeString;
}
private String typeString;
}
/**
* Describes changes made to an element.
*/
public interface ElementChange {
/**
* Returns the element represented. This is the element
* that was changed.
*
* @return the element
*/
public Element getElement();
/**
* Fetches the index within the element represented.
* This is the location that children were added
* and/or removed.
*
* @return the index
*/
public int getIndex();
/**
* Gets the child elements that were removed from the
* given parent element. The parent element is expected
* to be one of the elements listed in the elementsModified
* method. The element array returned is sorted in the
* order that the elements used to lie in the document.
*
* @return the child elements
*/
public Element[] getChildrenRemoved();
/**
* Gets the child elements that were added to the given
* parent element. The parent element is expected to be
* one of the elements given in the elementsModified method.
* The element array returned is sorted in the order that
* the elements lie in the document.
*
* @return the child elements
*/
public Element[] getChildrenAdded();
}
}