blob: 72c47f2bcee9fdbc71e874e96441a24d7de629d3 [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:15:47 CDT 2008 -->
<TITLE>
IBuffer
</TITLE>
<META NAME="keywords" CONTENT="org.eclipse.wst.jsdt.core.IBuffer interface">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="IBuffer";
}
</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/IBuffer.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/IAccessRule.html" title="interface in org.eclipse.wst.jsdt.core"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/eclipse/wst/jsdt/core/IBuffer.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="IBuffer.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;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&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</FONT>
<BR>
Interface IBuffer</H2>
<HR>
<DL>
<DT><PRE>public interface <B>IBuffer</B></DL>
</PRE>
<P>
A buffer contains the text contents of a resource. It is not language-specific.
The contents may be in the process of being edited, differing from the actual contents of the
underlying resource. A buffer has an owner, which is an <code>IOpenable</code>.
If a buffer does not have an underlying resource, saving the buffer has no effect.
Buffers can be read-only.
<p>
Note that javaScript model operations that manipulate an <code>IBuffer</code> (for example,
<code>IType.createMethod(...)</code>) ensures that the same line delimiter
(either <code>"\n"</code> or <code>"\r"</code> or <code>"\r\n"</code>) is
used across the whole buffer. Thus these operations may change the line delimiter(s)
included in the string to be append, or replaced.
However implementers of this interface should be aware that other clients of <code>IBuffer</code>
might not do such transformations beforehand.
<p>
This interface may be implemented by clients.
</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>
<!-- ========== 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>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#addBufferChangedListener(org.eclipse.wst.jsdt.core.IBufferChangedListener)">addBufferChangedListener</A></B>(<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core">IBufferChangedListener</A>&nbsp;listener)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds the given listener for changes to this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#append(char[])">append</A></B>(char[]&nbsp;text)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Appends the given character array to the contents of the buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#append(java.lang.String)">append</A></B>(java.lang.String&nbsp;text)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Appends the given string to the contents of the buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#close()">close</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Closes the buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;char</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getChar(int)">getChar</A></B>(int&nbsp;position)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the character at the given position in this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;char[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getCharacters()">getCharacters</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the contents of this buffer as a character array, or <code>null</code> if
the buffer has not been initialized.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getContents()">getContents</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the contents of this buffer as a <code>String</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getLength()">getLength</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns number of characters stored in this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/eclipse/wst/jsdt/core/IOpenable.html" title="interface in org.eclipse.wst.jsdt.core">IOpenable</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getOwner()">getOwner</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the JavaScript openable element owning of this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getText(int, int)">getText</A></B>(int&nbsp;offset,
int&nbsp;length)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the given range of text in this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;IResource</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#getUnderlyingResource()">getUnderlyingResource</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the underlying resource for which this buffer was opened,
or <code>null</code> if this buffer was not opened on a resource.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#hasUnsavedChanges()">hasUnsavedChanges</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns whether this buffer has been modified since it
was opened or since it was last saved.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#isClosed()">isClosed</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns whether this buffer has been closed.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#isReadOnly()">isReadOnly</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns whether this buffer is read-only.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#removeBufferChangedListener(org.eclipse.wst.jsdt.core.IBufferChangedListener)">removeBufferChangedListener</A></B>(<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core">IBufferChangedListener</A>&nbsp;listener)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Removes the given listener from this buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#replace(int, int, char[])">replace</A></B>(int&nbsp;position,
int&nbsp;length,
char[]&nbsp;text)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Replaces the given range of characters in this buffer with the given text.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#replace(int, int, java.lang.String)">replace</A></B>(int&nbsp;position,
int&nbsp;length,
java.lang.String&nbsp;text)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Replaces the given range of characters in this buffer with the given text.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#save(IProgressMonitor, boolean)">save</A></B>(IProgressMonitor&nbsp;progress,
boolean&nbsp;force)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Saves the contents of this buffer to its underlying resource.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#setContents(char[])">setContents</A></B>(char[]&nbsp;contents)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the contents of this buffer to the given character array.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/eclipse/wst/jsdt/core/IBuffer.html#setContents(java.lang.String)">setContents</A></B>(java.lang.String&nbsp;contents)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the contents of this buffer to the given <code>String</code>.</TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ 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="addBufferChangedListener(org.eclipse.wst.jsdt.core.IBufferChangedListener)"><!-- --></A><H3>
addBufferChangedListener</H3>
<PRE>
void <B>addBufferChangedListener</B>(<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core">IBufferChangedListener</A>&nbsp;listener)</PRE>
<DL>
<DD>Adds the given listener for changes to this buffer.
Has no effect if an identical listener is already registered or if the buffer
is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>listener</CODE> - the listener of buffer changes</DL>
</DD>
</DL>
<HR>
<A NAME="append(char[])"><!-- --></A><H3>
append</H3>
<PRE>
void <B>append</B>(char[]&nbsp;text)</PRE>
<DL>
<DD>Appends the given character array to the contents of the buffer.
This buffer will now have unsaved changes.
Any client can append to the contents of the buffer, not just the owner of the buffer.
Reports a buffer changed event.
<p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the given character array to append to contents of the buffer</DL>
</DD>
</DL>
<HR>
<A NAME="append(java.lang.String)"><!-- --></A><H3>
append</H3>
<PRE>
void <B>append</B>(java.lang.String&nbsp;text)</PRE>
<DL>
<DD>Appends the given string to the contents of the buffer.
This buffer will now have unsaved changes.
Any client can append to the contents of the buffer, not just the owner of the buffer.
Reports a buffer changed event.
<p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the <code>String</code> to append to the contents of the buffer</DL>
</DD>
</DL>
<HR>
<A NAME="close()"><!-- --></A><H3>
close</H3>
<PRE>
void <B>close</B>()</PRE>
<DL>
<DD>Closes the buffer. Any unsaved changes are lost. Reports a buffer changed event
with a 0 offset and a 0 length. When this event is fired, the buffer should already
be closed.
<p>
Further operations on the buffer are not allowed, except for close. If an
attempt is made to close an already closed buffer, the second attempt has no effect.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getChar(int)"><!-- --></A><H3>
getChar</H3>
<PRE>
char <B>getChar</B>(int&nbsp;position)</PRE>
<DL>
<DD>Returns the character at the given position in this buffer.
<p>
The returned value is undefined if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>position</CODE> - a zero-based source offset in this buffer
<DT><B>Returns:</B><DD>the character at the given position in this buffer</DL>
</DD>
</DL>
<HR>
<A NAME="getCharacters()"><!-- --></A><H3>
getCharacters</H3>
<PRE>
char[] <B>getCharacters</B>()</PRE>
<DL>
<DD>Returns the contents of this buffer as a character array, or <code>null</code> if
the buffer has not been initialized.
<p>
Callers should make no assumption about whether the returned character array
is or is not the genuine article or a copy. In other words, if the client
wishes to change this array, they should make a copy. Likewise, if the
client wishes to hang on to the array in its current state, they should
make a copy.
</p><p>
The returned value is undefined if the buffer is closed.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the characters contained in this buffer</DL>
</DD>
</DL>
<HR>
<A NAME="getContents()"><!-- --></A><H3>
getContents</H3>
<PRE>
java.lang.String <B>getContents</B>()</PRE>
<DL>
<DD>Returns the contents of this buffer as a <code>String</code>. Like all strings,
the result is an immutable value object., It can also answer <code>null</code> if
the buffer has not been initialized.
<p>
The returned value is undefined if the buffer is closed.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the contents of this buffer as a <code>String</code></DL>
</DD>
</DL>
<HR>
<A NAME="getLength()"><!-- --></A><H3>
getLength</H3>
<PRE>
int <B>getLength</B>()</PRE>
<DL>
<DD>Returns number of characters stored in this buffer.
<p>
The returned value is undefined if the buffer is closed.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the number of characters in this buffer</DL>
</DD>
</DL>
<HR>
<A NAME="getOwner()"><!-- --></A><H3>
getOwner</H3>
<PRE>
<A HREF="../../../../../org/eclipse/wst/jsdt/core/IOpenable.html" title="interface in org.eclipse.wst.jsdt.core">IOpenable</A> <B>getOwner</B>()</PRE>
<DL>
<DD>Returns the JavaScript openable element owning of this buffer.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the openable element owning this buffer</DL>
</DD>
</DL>
<HR>
<A NAME="getText(int, int)"><!-- --></A><H3>
getText</H3>
<PRE>
java.lang.String <B>getText</B>(int&nbsp;offset,
int&nbsp;length)</PRE>
<DL>
<DD>Returns the given range of text in this buffer.
<p>
The returned value is undefined if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the zero-based starting offset<DD><CODE>length</CODE> - the number of characters to retrieve
<DT><B>Returns:</B><DD>the given range of text in this buffer</DL>
</DD>
</DL>
<HR>
<A NAME="getUnderlyingResource()"><!-- --></A><H3>
getUnderlyingResource</H3>
<PRE>
IResource <B>getUnderlyingResource</B>()</PRE>
<DL>
<DD>Returns the underlying resource for which this buffer was opened,
or <code>null</code> if this buffer was not opened on a resource.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the underlying resource for this buffer, or <code>null</code>
if none.</DL>
</DD>
</DL>
<HR>
<A NAME="hasUnsavedChanges()"><!-- --></A><H3>
hasUnsavedChanges</H3>
<PRE>
boolean <B>hasUnsavedChanges</B>()</PRE>
<DL>
<DD>Returns whether this buffer has been modified since it
was opened or since it was last saved.
If a buffer does not have an underlying resource, this method always
returns <code>true</code>.
<p>
NOTE: when a buffer does not have unsaved changes, the model may decide to close it
to claim some memory back. If the associated element needs to be reopened later on, its
buffer factory will be requested to create a new buffer.
</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>boolean</code> indicating presence of unsaved changes (in
the absence of any underlying resource, it will always return <code>true</code>).</DL>
</DD>
</DL>
<HR>
<A NAME="isClosed()"><!-- --></A><H3>
isClosed</H3>
<PRE>
boolean <B>isClosed</B>()</PRE>
<DL>
<DD>Returns whether this buffer has been closed.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>boolean</code> indicating whether this buffer is closed.</DL>
</DD>
</DL>
<HR>
<A NAME="isReadOnly()"><!-- --></A><H3>
isReadOnly</H3>
<PRE>
boolean <B>isReadOnly</B>()</PRE>
<DL>
<DD>Returns whether this buffer is read-only.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>boolean</code> indicating whether this buffer is read-only</DL>
</DD>
</DL>
<HR>
<A NAME="removeBufferChangedListener(org.eclipse.wst.jsdt.core.IBufferChangedListener)"><!-- --></A><H3>
removeBufferChangedListener</H3>
<PRE>
void <B>removeBufferChangedListener</B>(<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core">IBufferChangedListener</A>&nbsp;listener)</PRE>
<DL>
<DD>Removes the given listener from this buffer.
Has no affect if an identical listener is not registered or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>listener</CODE> - the listener</DL>
</DD>
</DL>
<HR>
<A NAME="replace(int, int, char[])"><!-- --></A><H3>
replace</H3>
<PRE>
void <B>replace</B>(int&nbsp;position,
int&nbsp;length,
char[]&nbsp;text)</PRE>
<DL>
<DD>Replaces the given range of characters in this buffer with the given text.
<code>position</code> and <code>position + length</code> must be in the range [0, getLength()].
<code>length</code> must not be negative.
<p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>position</CODE> - the zero-based starting position of the affected text range in this buffer<DD><CODE>length</CODE> - the length of the affected text range in this buffer<DD><CODE>text</CODE> - the replacing text as a character array</DL>
</DD>
</DL>
<HR>
<A NAME="replace(int, int, java.lang.String)"><!-- --></A><H3>
replace</H3>
<PRE>
void <B>replace</B>(int&nbsp;position,
int&nbsp;length,
java.lang.String&nbsp;text)</PRE>
<DL>
<DD>Replaces the given range of characters in this buffer with the given text.
<code>position</code> and <code>position + length</code> must be in the range [0, getLength()].
<code>length</code> must not be negative.
<p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>position</CODE> - the zero-based starting position of the affected text range in this buffer<DD><CODE>length</CODE> - the length of the affected text range in this buffer<DD><CODE>text</CODE> - the replacing text as a <code>String</code></DL>
</DD>
</DL>
<HR>
<A NAME="save(IProgressMonitor, boolean)"><!-- --></A><H3>
save</H3>
<PRE>
void <B>save</B>(IProgressMonitor&nbsp;progress,
boolean&nbsp;force)
throws <A HREF="../../../../../org/eclipse/wst/jsdt/core/JavaScriptModelException.html" title="class in org.eclipse.wst.jsdt.core">JavaScriptModelException</A></PRE>
<DL>
<DD>Saves the contents of this buffer to its underlying resource. If
successful, this buffer will have no unsaved changes.
The buffer is left open. Saving a buffer with no unsaved
changes has no effect - the underlying resource is not changed.
If the buffer does not have an underlying resource or is read-only, this
has no effect.
<p>
The <code>force</code> parameter controls how this method deals with
cases where the workbench is not completely in sync with the local file system.
If <code>false</code> is specified, this method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workbench. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if <code>true</code> is specified, an attempt will be made
to write a corresponding file in the local file system,
overwriting any existing one if need be.
In either case, if this method succeeds, the resource will be marked
as being local (even if it wasn't before).
<p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>progress</CODE> - the progress monitor to notify<DD><CODE>force</CODE> - a <code> boolean </code> flag indicating how to deal with resource
inconsistencies.
<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 an error occurs writing the buffer
to the underlying resource<DT><B>See Also:</B><DD><CODE>org.eclipse.core.resources.IFile#setContents(java.io.InputStream, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="setContents(char[])"><!-- --></A><H3>
setContents</H3>
<PRE>
void <B>setContents</B>(char[]&nbsp;contents)</PRE>
<DL>
<DD>Sets the contents of this buffer to the given character array.
This buffer will now have unsaved changes.
Any client can set the contents of the buffer, not just the owner of the buffer.
Reports a buffer changed event.
<p>
Equivalent to <code>replace(0,getLength(),contents)</code>.
</p><p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>contents</CODE> - the new contents of this buffer as a character array</DL>
</DD>
</DL>
<HR>
<A NAME="setContents(java.lang.String)"><!-- --></A><H3>
setContents</H3>
<PRE>
void <B>setContents</B>(java.lang.String&nbsp;contents)</PRE>
<DL>
<DD>Sets the contents of this buffer to the given <code>String</code>.
This buffer will now have unsaved changes.
Any client can set the contents of the buffer, not just the owner of the buffer.
Reports a buffer changed event.
<p>
Equivalent to <code>replace(0,getLength(),contents)</code>.
</p><p>
Has no effect if this buffer is read-only or if the buffer is closed.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>contents</CODE> - the new contents of this buffer as a <code>String</code></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/IBuffer.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/IAccessRule.html" title="interface in org.eclipse.wst.jsdt.core"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/eclipse/wst/jsdt/core/IBufferChangedListener.html" title="interface in org.eclipse.wst.jsdt.core"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/eclipse/wst/jsdt/core/IBuffer.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="IBuffer.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;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&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>