Class WebSocketMessage
- java.lang.Object
-
- com.facilita.fc.web.WebSocketMessage
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class WebSocketMessage extends java.lang.Object implements java.lang.AutoCloseableRepresents a message that can be sent or received over aWebSocket
-
-
Constructor Summary
Constructors Constructor Description WebSocketMessage(long cPtr, boolean cMemoryOwn)For internal use only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()(non-Javadoc)voiddelete()java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects, and specifying whether the search will be case-sensitive.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects specifying what action to take in case of failure.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, specifying whether the search will be case-sensitive.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, and specifying what action to take in case of failure.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)Extracts text from the message content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before)Extracts text from the message content starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive)Extracts text from the message content starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction)Extracts text from the message content starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive)Extracts text from the message content starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue)Extracts text from the message content starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)Extracts text from the message content starting from the end.RegExpMatchListextractRegExp(ExtractionCursor cursor, java.lang.String regExp)Extracts multiple string objects from the message content, wherever the specified regular expression matches.RegExpMatchListextractRegExp(ExtractionCursor cursor, java.lang.String regExp, boolean caseSensitive)Extracts multiple string objects from the message content, wherever the specified regular expression matches, and specifying whether the search will be case-sensitive.java.lang.StringextractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp)Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found.java.lang.StringextractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.StringextractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, ActionType failAction)Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, and specifying the action to take on failure.java.lang.StringextractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, ActionType failAction, boolean caseSensitive)Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, specifying whether the search will be case-sensitive, and specifying the action to take on failure.booleanfind(ExtractionCursor cursor, java.lang.String text)Finds the specifiedtextwithin this WebSocketMessagebooleanfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)Finds the specifiedtextwithin this WebSocketMessage, specifying whether the search will be case-sensitive.booleanfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction)Finds the specifiedtextwithin this WebSocketMessage, and what action to take in case of failure.booleanfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)Finds the specifiedtextwithin this WebSocketMessage, specifying whether the search will be case-sensitive, and what action to take in case of failure.org.w3c.dom.DocumentgetAsXml()Gets an XML DOM representation of this message.java.lang.StringgetCharEncoding()Gets the encoding to use to decode text in this message.static longgetCPtr(WebSocketMessage obj)For internal use only.intgetLength()Gets the length in bytes of this messagebyte[]getRawData()Get the contents of the message.java.lang.StringgetText()Get the contents of the message.booleanisBinary()Gets a value indicating whether this message is a binary message.booleanrfind(ExtractionCursor cursor, java.lang.String text)Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content.booleanrfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, and specifying whether the search will be case-sensitive.booleanrfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction)Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, and what action to take in case of failure.booleanrfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, specifying whether the search will be case-sensitive, and what action to take in case of failure.voidsetCharEncoding(java.lang.String charEncoding)Sets the encoding to use to decode text in this message.booleanverifyContains(java.lang.String text)Determines whether the content of this WebSocketMessage contains the specifiedtext.booleanverifyContains(java.lang.String text, boolean caseSensitive)Determines whether the content of this WebSocketMessage contains the specifiedtext, specifying whether the search will be case-sensitive.booleanverifyContains(java.lang.String text, ActionType failAction)Determines whether the content of this WebSocketMessage contains the specifiedtext, and specifying the action to take on failure.booleanverifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive)Determines whether the content of this WebSocketMessage contains the specifiedtext, specifying whether the search will be case-sensitive, and specifying the action to take on failure.
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(WebSocketMessage obj)
For internal use only. Of no interest to the user.- Parameters:
obj- A reference to an object of this class.- Returns:
- A handle containing the address of the CPP wrapped object.
-
delete
public void delete()
-
close
public void close() throws java.lang.Exception(non-Javadoc)- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception- See Also:
AutoCloseable.close()
-
getRawData
public byte[] getRawData()
Get the contents of the message.If the message is a text message, then use
getText()instead.- Returns:
- the contents of the message.
- See Also:
getText(),isBinary()
-
getText
public java.lang.String getText() throws java.io.UnsupportedEncodingExceptionGet the contents of the message.Gets the contents of the message by decoding the
getRawData()using the currentgetCharEncoding().- Returns:
- the contents of the message.
- Throws:
java.io.UnsupportedEncodingException- The currentgetCharEncoding()is not supported.- See Also:
getRawData(),getCharEncoding(),isBinary()
-
getAsXml
public org.w3c.dom.Document getAsXml() throws java.lang.ExceptionGets an XML DOM representation of this message.This is useful if the contents of the message is XML data.
- Returns:
- an XML DOM representation of this message.
- Throws:
java.lang.Exception- An error occurred
-
isBinary
public boolean isBinary()
Gets a value indicating whether this message is a binary message.- Returns:
- Returns
trueif this is a binary message, orfalseif this is a text message.
-
getLength
public int getLength()
Gets the length in bytes of this message- Returns:
- the length in bytes of this message
-
setCharEncoding
public void setCharEncoding(java.lang.String charEncoding)
Sets the encoding to use to decode text in this message.Defaults to UTF-8.
- Parameters:
charEncoding- the encoding to use to decode text in this message.- See Also:
getCharEncoding(),getRawData(),getText(),isBinary()
-
getCharEncoding
public java.lang.String getCharEncoding()
Gets the encoding to use to decode text in this message.Defaults to UTF-8.
- Returns:
- the encoding to use to decode text in this message.
- See Also:
setCharEncoding(String),getRawData(),getText(),isBinary()
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.find(cursor, "some text", false)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessageInformation about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search is case-sensitive.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.find(cursor, "some text")) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.rfind(cursor, "some text", false)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.rfind(cursor, "some text")) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json, defaulting to "Joe Jones" if the value cannot be found // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\"", "Joe Jones", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects - returning thedefaultValueif they cannot be found.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json, defaulting to "Joe Jones" if the value cannot be found // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\"", "Joe Jones"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\"", "00000", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects - returning thedefaultValueif they cannot be found.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\"", "00000"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\"", "Joe Jones", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\"", "Joe Jones"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, an empty string will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, an empty string will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, an empty string will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\"", ActionType.ACT_WARNING, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- The action to take if the text cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the message content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, an empty string will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = webSocket_message.extractFromEnd( cursor, "\"", "value=\"", ActionType.ACT_WARNING); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- This text is searched for in the message content, and the returned string starts immediately before this text occurs in the content.before- This text is searched for in the message content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- The action to take if the text cannot be found.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\"", "volvo", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\"", "volvo"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif the extract failed. - Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\"", ActionType.ACT_WARNING, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- The action to take if the text cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the message content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring objects will be returned.Supplying a
List<String>of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbeforeis matched.The following example demonstrates extracting text from a WebSocket message.
try (WebSocketMessage webSocket_message = ((WebSocketMessageQueue)get("webSocketMessageQueue")).getNextMessage(60000)) { ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = webSocket_message.extractFromEnd( cursor, after, "value=\"", ActionType.ACT_WARNING); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); } }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.after- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately before all the string objects have been matched in the content.before- This text is searched for in the response content after theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- The action to take if the text cannot be found.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
extractRegExp
public RegExpMatchList extractRegExp(ExtractionCursor cursor, java.lang.String regExp, boolean caseSensitive)
Extracts multiple string objects from the message content, wherever the specified regular expression matches, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting HTML comments from an HTML Response.
ExtractionCursor cursor = new ExtractionCursor(); // write out the HTML comment lines in the current web page RegExpMatchList matches = webSocketMessage.extractRegExp( cursor, <![CDATA["<!--.*?-->"]]>, true); for (int i = 0; i < matches.getCount(); i++) { writeMessage(matches[i].Match); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.regExp- The regular expression to match.caseSensitive-trueif the search should be case-sensitive.- Returns:
- A
RegExpMatchListcontaining the list of matches.
-
extractRegExp
public RegExpMatchList extractRegExp(ExtractionCursor cursor, java.lang.String regExp)
Extracts multiple string objects from the message content, wherever the specified regular expression matches.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitiveThe following example demonstrates extracting HTML comments from an HTML Response.
ExtractionCursor cursor = new ExtractionCursor(); // write out the HTML comment lines in the current web page RegExpMatchList matches = webSocketMessage.extractRegExp( cursor, <![CDATA["<!--.*?-->"]]>); for (int i = 0; i < matches.getCount(); i++) { writeMessage(matches[i].Match); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.regExp- The regular expression to match.- Returns:
- A
RegExpMatchListcontaining the list of matches.
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, and specifying whether the search will be case-sensitive.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from some HTML.
ExtractionCursor cursor = new ExtractionCursor(); // <![CDATA[<script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\]]> String extractedText = webSocketMessage.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";", true); if (cursor.succeeded()) { writeMessage(string.Format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.beforeRegExp- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.afterRegExp- This text is searched for in the message content after thebeforeRegExptext has been found, and the returned string ends immediately before this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from some HTML.
ExtractionCursor cursor = new ExtractionCursor(); // <![CDATA[<script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\]]> String extractedText = webSocketMessage.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";"); if (cursor.succeeded()) { writeMessage(string.Format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.beforeRegExp- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.afterRegExp- This text is searched for in the message content after thebeforeRegExptext has been found, and the returned string ends immediately before this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
verifyContains
public boolean verifyContains(java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingExceptionDetermines whether the content of this WebSocketMessage contains the specifiedtext, specifying whether the search will be case-sensitive.The following example demonstrates verifying that a string appears within the content of a message.
// Check that the login succeeded. if (!webSocketMessage.verifyContains("Login successful", false)) { error("Login failed"); nextIteration(); }- Parameters:
text- The text to look for.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the text was found; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
verifyContains
public boolean verifyContains(java.lang.String text) throws java.io.UnsupportedEncodingExceptionDetermines whether the content of this WebSocketMessage contains the specifiedtext.The search will be case=sensitive. The following example demonstrates verifying that a string appears within the content of a message.
// Check that the login succeeded. if (!webSocketMessage.verifyContains("Login successful")) { error("Login failed"); nextIteration(); }- Parameters:
text- The text to look for.- Returns:
trueif the text was found; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, specifying whether the search will be case-sensitive, and what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.find(cursor, "some text", ActionType.ACT_NONE, false)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.failAction- The action to take iftextcannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, ActionType failAction) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, and what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search is case-sensitive.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.find(cursor, "some text", ActionType.ACT_NONE)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.failAction- The action to take iftextcannot be found.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, specifying whether the search will be case-sensitive, and what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.rfind(cursor, "some text", ActionType.ACT_NONE, false)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.failAction- The action to take iftextcannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction) throws java.io.UnsupportedEncodingException
Finds the specifiedtextwithin this WebSocketMessage, starting from the end of the content, and what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates finding text within a WebSocketMessage.
ExtractionCursor cursor = new ExtractionCursor(); if (!webSocketMessage.rfind(cursor, "some text", ActionType.ACT_NONE)) { warn("some text not found: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(string.format("Text found at position %d", cursor.getIndex()));- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.text- The text to search for.failAction- The action to take iftextcannot be found.- Returns:
trueif the specifiedtextwas found in this WebSocketMessage; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects, specifying whether the search will be case-sensitive, and what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\"", ActionType.ACT_ERROR, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeandafterstring objects specifying what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the json // {"value":"Joe Smith"} String extractedText = webSocketMessage.extract( cursor, "\value\":\"", "\"", ActionType.ACT_ERROR); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\"", ActionType.ACT_ERROR, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specified list ofbeforeandafterstring objects, and specifying what action to take in case of failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from a message.
ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = webSocketMessage.extract( cursor, before, "\"", ActionType.ACT_ERROR); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.before- Each string in this List is searched for sequentially in the message content, and the returned string starts immediately after all the string objects have been matched in the content.after- This text is searched for in the message content after thebeforetext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, specifying whether the search will be case-sensitive, and specifying the action to take on failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed.The following example demonstrates extracting text from some HTML.
ExtractionCursor cursor = new ExtractionCursor(); // <![CDATA[<script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\]]> String extractedText = webSocketMessage.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";", ActionType.ACT_ERROR, true); if (cursor.succeeded()) { writeMessage(string.Format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.beforeRegExp- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.afterRegExp- This text is searched for in the message content after thebeforeRegExptext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the message content - everything between (but not including) the specifiedbeforeRegExpandafterRegExpstring objects - returning an empty string if they cannot be found, and specifying the action to take on failure.Information about the success/failure of this method will be stored in the
ExtractionCursorobject passed. The search will be case-sensitive.The following example demonstrates extracting text from some HTML.
ExtractionCursor cursor = new ExtractionCursor(); // <![CDATA[<script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\]]> String extractedText = webSocketMessage.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";", ActionType.ACT_ERROR); if (cursor.succeeded()) { writeMessage(string.Format("The value %s was found at position %d", extractedText, cursor.getIndex())); }- Parameters:
cursor- AnExtractionCursorobject to store the success/failure of the action, and the index in the message at which the match was found.beforeRegExp- This text is searched for in the message content, and the returned string starts immediately after this text occurs in the content.afterRegExp- This text is searched for in the message content after thebeforeRegExptext has been found, and the returned string ends immediately before this text occurs in the content.failAction- The action to take if the extract fails.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
verifyContains
public boolean verifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingExceptionDetermines whether the content of this WebSocketMessage contains the specifiedtext, specifying whether the search will be case-sensitive, and specifying the action to take on failure.The following example demonstrates verifying that a string appears within the content of a message.
// Check that the login succeeded. if (!webSocketMessage.verifyContains("Login successful", ActionType.ACT_ERROR, false)) { nextIteration(); }- Parameters:
text- The text to look for.failAction- The action to take if the text cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
trueif the text was found; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
verifyContains
public boolean verifyContains(java.lang.String text, ActionType failAction) throws java.io.UnsupportedEncodingExceptionDetermines whether the content of this WebSocketMessage contains the specifiedtext, and specifying the action to take on failure.The following example demonstrates verifying that a string appears within the content of a message. the search will be case-sensitive.
// Check that the login succeeded. if (!webSocketMessage.verifyContains("Login successful", ActionType.ACT_ERROR)) { nextIteration(); }- Parameters:
text- The text to look for.failAction- The action to take if the text cannot be found.- Returns:
trueif the text was found; otherwise,false.- Throws:
java.io.UnsupportedEncodingException- The specified encoding is not supported.
-
-