blob: 6d9fd5271afc11f146662d62c885344b3c8977ec [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_12) on Fri May 30 11:16:01 CDT 2008 -->
<TITLE>
JavaScriptUnitSorter
</TITLE>
<META NAME="keywords" CONTENT="org.eclipse.wst.jsdt.core.util.JavaScriptUnitSorter class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="JavaScriptUnitSorter";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JavaScriptUnitSorter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/IModifierConstants.html" title="interface in org.eclipse.wst.jsdt.core.util"><B>PREV CLASS</B></A>&nbsp;
&nbsp;NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="JavaScriptUnitSorter.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.eclipse.wst.jsdt.core.util</FONT>
<BR>
Class JavaScriptUnitSorter</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../../resources/inherit.gif" ALT="extended by "><B>org.eclipse.wst.jsdt.core.util.JavaScriptUnitSorter</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>JavaScriptUnitSorter</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Operation for sorting members within a javascript unit .
<p>
This class provides all functionality via static members; it is not
intended to be instantiated or subclassed.
</p>
Provisional API: This class/interface is part of an interim API that is still under development and expected to
change significantly before reaching stability. It is being made available at this early stage to solicit feedback
from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
(repeatedly) as the API evolves.
<P>
<P>
<HR>
<P>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html#RELATIVE_ORDER">RELATIVE_ORDER</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name of auxillary property whose value can be used to determine the
original relative order of two body declarations.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html#sort(int, org.eclipse.wst.jsdt.core.IJavaScriptUnit, int[], java.util.Comparator, int, IProgressMonitor)">sort</A></B>(int&nbsp;level,
<A HREF="../../../../../../org/eclipse/wst/jsdt/core/IJavaScriptUnit.html" title="interface in org.eclipse.wst.jsdt.core">IJavaScriptUnit</A>&nbsp;compilationUnit,
int[]&nbsp;positions,
java.util.Comparator&nbsp;comparator,
int&nbsp;options,
IProgressMonitor&nbsp;monitor)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reorders the declarations in the given javascript unit according to
the specified AST level.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;TextEdit</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html#sort(org.eclipse.wst.jsdt.core.dom.JavaScriptUnit, java.util.Comparator, int, TextEditGroup, IProgressMonitor)">sort</A></B>(<A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/JavaScriptUnit.html" title="class in org.eclipse.wst.jsdt.core.dom">JavaScriptUnit</A>&nbsp;unit,
java.util.Comparator&nbsp;comparator,
int&nbsp;options,
TextEditGroup&nbsp;group,
IProgressMonitor&nbsp;monitor)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reorders the declarations in the given javascript unit according to the
specified comparator.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="RELATIVE_ORDER"><!-- --></A><H3>
RELATIVE_ORDER</H3>
<PRE>
public static final java.lang.String <B>RELATIVE_ORDER</B></PRE>
<DL>
<DD>Name of auxillary property whose value can be used to determine the
original relative order of two body declarations. This allows a
comparator to preserve the relative positions of certain kinds of
body declarations when required.
<p>
All body declarations passed to the comparator's <code>compare</code>
method by <code>JavaScriptUnitSorter.sort</code> carry an
Integer-valued property. The body declaration with the lower value
comes before the one with the higher value. The exact numeric value
of these properties is unspecified.
</p>
<p>
Example usage:
<pre>
BodyDeclaration b1 = (BodyDeclaration) object1;
BodyDeclaration b2 = (BodyDeclaration) object2;
Integer i1 = (Integer) b1.getProperty(RELATIVE_ORDER);
Integer i2 = (Integer) b2.getProperty(RELATIVE_ORDER);
return i1.intValue() - i2.intValue(); // preserve original order
</pre>
</p>
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/BodyDeclaration.html" title="class in org.eclipse.wst.jsdt.core.dom"><CODE>BodyDeclaration</CODE></A>,
<A HREF="../../../../../../constant-values.html#org.eclipse.wst.jsdt.core.util.JavaScriptUnitSorter.RELATIVE_ORDER">Constant Field Values</A></DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="sort(int, org.eclipse.wst.jsdt.core.IJavaScriptUnit, int[], java.util.Comparator, int, IProgressMonitor)"><!-- --></A><H3>
sort</H3>
<PRE>
public static void <B>sort</B>(int&nbsp;level,
<A HREF="../../../../../../org/eclipse/wst/jsdt/core/IJavaScriptUnit.html" title="interface in org.eclipse.wst.jsdt.core">IJavaScriptUnit</A>&nbsp;compilationUnit,
int[]&nbsp;positions,
java.util.Comparator&nbsp;comparator,
int&nbsp;options,
IProgressMonitor&nbsp;monitor)
throws <A HREF="../../../../../../org/eclipse/wst/jsdt/core/JavaScriptModelException.html" title="class in org.eclipse.wst.jsdt.core">JavaScriptModelException</A></PRE>
<DL>
<DD>Reorders the declarations in the given javascript unit according to
the specified AST level. The caller is responsible for arranging in
advance that the given javascript unit is a working copy, and for
saving the changes afterwards.
<p>
<b>Note:</b> Reordering the members within a type declaration might be
more than a cosmetic change and could have potentially serious
repercussions. Firstly, the order in which the fields of a type are
initialized is significant in the JavaScript language; reordering fields
and initializers may result in compilation errors or change the execution
behavior of the code. Secondly, reordering a class's members may affect
how its instances are serialized. This operation should therefore be used
with caution and due concern for potential negative side effects.
</p>
<p>
The optional <code>positions</code> array contains a non-decreasing
ordered list of character-based source positions within the compilation
unit's source code string. Upon return from this method, the positions in
the array reflect the corresponding new locations in the modified source
code string. Note that this operation modifies the given array in place.
</p>
<p>
The <code>compare</code> method of the given comparator is passed pairs
of body declarations (subclasses of <code>BodyDeclaration</code>)
representing body declarations at the same level. The nodes are from an
AST of the specified level
(<A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/ASTParser.html#newParser(int)"><CODE>ASTParser.newParser(int)</CODE></A>. Clients
will generally specify AST.JLS3 since that will cover all constructs found
in JavaScript 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 source code.
The comparator is called on body declarations of nested classes, including
anonymous and local classes, but always at the same level. Clients need to provide
a comparator implementation (there is no standard comparator). The
<code>RELATIVE_ORDER</code> property attached to these AST nodes afforts
the comparator a way to preserve the original relative order.
</p>
<p>
The body declarations passed as parameters to the comparator
always carry at least the following minimal signature information:
<br>
<table border="1" width="80%" cellpadding="5">
<tr>
<td width="20%"><code>TypeDeclaration</code></td>
<td width="50%"><code>modifiers, isInterface, name, superclass,
superInterfaces, typeParameters<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>FieldDeclaration</code></td>
<td width="50%"><code>modifiers, type, fragments
(VariableDeclarationFragments
with name only)<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>FunctionDeclaration</code></td>
<td width="50%"><code>modifiers, isConstructor, returnType, name,
typeParameters, parameters
(SingleVariableDeclarations with name, type, and modifiers only),
thrownExceptions<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>Initializer</code></td>
<td width="50%"><code>modifiers<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>AnnotationTypeDeclaration</code></td>
<td width="50%"><code>modifiers, name<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>AnnotationTypeMemberDeclaration</code></td>
<td width="50%"><code>modifiers, name, type, default<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>EnumDeclaration</code></td>
<td width="50%"><code>modifiers, name, superInterfaces<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>EnumConstantDeclaration</code></td>
<td width="50%"><code>modifiers, name, arguments<br>
RELATIVE_ORDER property</code></td>
</tr>
</table>
Clients should not rely on the AST nodes being properly parented or on
having source range information. (Future releases may provide options
for requesting additional information like source positions, full ASTs,
non-recursive sorting, etc.)
</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>level</CODE> - the AST level; one of the AST LEVEL constants<DD><CODE>compilationUnit</CODE> - the given javascript unit , which must be a
working copy<DD><CODE>positions</CODE> - an array of source positions to map, or
<code>null</code> if none. If supplied, the positions must
character-based source positions within the original source code for
the given javascript unit , arranged in non-decreasing order.
The array is updated in place when this method returns to reflect the
corresponding source positions in the permuted source code string
(but not necessarily any longer in non-decreasing order).<DD><CODE>comparator</CODE> - the comparator capable of ordering
<code>BodyDeclaration</code>s; this comparator is passed AST nodes
from an AST of the specified AST level<DD><CODE>options</CODE> - bitwise-or of option flags; <code>0</code> for default
behavior (reserved for future growth)<DD><CODE>monitor</CODE> - the progress monitor to notify, or <code>null</code> if
none
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../../../org/eclipse/wst/jsdt/core/JavaScriptModelException.html" title="class in org.eclipse.wst.jsdt.core">JavaScriptModelException</A></CODE> - if the javascript unit could not be
sorted. Reasons include:
<ul>
<li> The given javascript unit does not exist (ELEMENT_DOES_NOT_EXIST)</li>
<li> The given javascript unit is not a working copy (INVALID_ELEMENT_TYPES)</li>
<li> A <code>CoreException</code> occurred while accessing the underlying
resource
</ul>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if the given javascript unit is null
or if the given comparator is null, or if <code>level</code> is not one of
the AST JLS level constants.<DT><B>See Also:</B><DD><A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/BodyDeclaration.html" title="class in org.eclipse.wst.jsdt.core.dom"><CODE>BodyDeclaration</CODE></A>,
<A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html#RELATIVE_ORDER"><CODE>RELATIVE_ORDER</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="sort(org.eclipse.wst.jsdt.core.dom.JavaScriptUnit, java.util.Comparator, int, TextEditGroup, IProgressMonitor)"><!-- --></A><H3>
sort</H3>
<PRE>
public static TextEdit <B>sort</B>(<A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/JavaScriptUnit.html" title="class in org.eclipse.wst.jsdt.core.dom">JavaScriptUnit</A>&nbsp;unit,
java.util.Comparator&nbsp;comparator,
int&nbsp;options,
TextEditGroup&nbsp;group,
IProgressMonitor&nbsp;monitor)
throws <A HREF="../../../../../../org/eclipse/wst/jsdt/core/JavaScriptModelException.html" title="class in org.eclipse.wst.jsdt.core">JavaScriptModelException</A></PRE>
<DL>
<DD>Reorders the declarations in the given javascript unit according to the
specified comparator. The caller is responsible for arranging in advance
that the given javascript unit is a working copy, and for applying the
returned TextEdit afterwards.
<p>
<b>Note:</b> Reordering the members within a type declaration might be
more than a cosmetic change and could have potentially serious
repercussions. Firstly, the order in which the fields of a type are
initialized is significant in the JavaScript language; reordering fields and
initializers may result in compilation errors or change the execution
behavior of the code. Secondly, reordering a class's members may affect
how its instances are serialized. This operation should therefore be used
with caution and due concern for potential negative side effects.
</p>
<p>
The <code>compare</code> method of the given comparator is passed pairs
of body declarations (subclasses of <code>BodyDeclaration</code>)
representing body declarations at the same level.
The comparator is called on body declarations of nested classes,
including anonymous and local classes, but always at the same level.
Clients need to provide a comparator implementation (there is no standard
comparator). The <code>RELATIVE_ORDER</code> property attached to these
AST nodes affords the comparator a way to preserve the original relative
order.
</p>
<p>
The body declarations passed as parameters to the comparator always carry
at least the following minimal signature information: <br>
<table border="1" width="80%" cellpadding="5">
<tr>
<td width="20%"><code>TypeDeclaration</code></td>
<td width="50%"><code>modifiers, isInterface, name, superclass,
superInterfaces, typeParameters<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>FieldDeclaration</code></td>
<td width="50%"><code>modifiers, type, fragments
(VariableDeclarationFragments
with name only)<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>FunctionDeclaration</code></td>
<td width="50%"><code>modifiers, isConstructor, returnType, name,
typeParameters, parameters
(SingleVariableDeclarations with name, type, and modifiers only),
thrownExceptions<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>Initializer</code></td>
<td width="50%"><code>modifiers<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>AnnotationTypeDeclaration</code></td>
<td width="50%"><code>modifiers, name<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>AnnotationTypeMemberDeclaration</code></td>
<td width="50%"><code>modifiers, name, type, default<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>EnumDeclaration</code></td>
<td width="50%"><code>modifiers, name, superInterfaces<br>
RELATIVE_ORDER property</code></td>
</tr>
<tr>
<td width="20%"><code>EnumConstantDeclaration</code></td>
<td width="50%"><code>modifiers, name, arguments<br>
RELATIVE_ORDER property</code></td>
</tr>
</table>
</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>unit</CODE> - the JavaScriptUnit to sort<DD><CODE>comparator</CODE> - the comparator capable of ordering
<code>BodyDeclaration</code>s; this comparator is passed
AST nodes from an AST of the specified AST level<DD><CODE>options</CODE> - bitwise-or of option flags; <code>0</code> for default
behavior (reserved for future growth)<DD><CODE>group</CODE> - the text edit group to use when generating text edits, or <code>null</code><DD><CODE>monitor</CODE> - the progress monitor to notify, or <code>null</code> if none
<DT><B>Returns:</B><DD>a TextEdit describing the required edits to do the sort, or <code>null</code>
if sorting is not required
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../../../org/eclipse/wst/jsdt/core/JavaScriptModelException.html" title="class in org.eclipse.wst.jsdt.core">JavaScriptModelException</A></CODE> - if the javascript unit could not be sorted. Reasons
include:
<ul>
<li> The given unit was not created from a IJavaScriptUnit (INVALID_ELEMENT_TYPES)</li>
</ul>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if the given javascript unit is null or if the given
comparator is null, or if <code>options</code> is not one
of the supported levels.<DT><B>See Also:</B><DD><A HREF="../../../../../../org/eclipse/wst/jsdt/core/dom/BodyDeclaration.html" title="class in org.eclipse.wst.jsdt.core.dom"><CODE>BodyDeclaration</CODE></A>,
<A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html#RELATIVE_ORDER"><CODE>RELATIVE_ORDER</CODE></A></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JavaScriptUnitSorter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../../org/eclipse/wst/jsdt/core/util/IModifierConstants.html" title="interface in org.eclipse.wst.jsdt.core.util"><B>PREV CLASS</B></A>&nbsp;
&nbsp;NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?org/eclipse/wst/jsdt/core/util/JavaScriptUnitSorter.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="JavaScriptUnitSorter.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>