com.planet_ink.coffee_mud.WebMacros
Class StdWebMacro

java.lang.Object
  extended by com.planet_ink.coffee_mud.WebMacros.StdWebMacro
All Implemented Interfaces:
CMObject, WebMacro, java.lang.Cloneable, java.lang.Comparable<CMObject>
Direct Known Subclasses:
AbilityAffectNext, AbilityBlessingNext, AbilityCursesNext, AbilityData, AbilityDomainNext, AbilityGainReport, AbilityID, AbilityName, AbilityNext, AbilityPlayerNext, AbilityPowersNext, AbilityRaceNext, AbilityRecipeData, AbilityTypeNext, AccountCreate, AccountData, AccountID, AccountNext, AccountOnline, AccountPlayerNext, AchievementData, AchievementID, AchievementNext, AddFile, AddRandomFile, AddRandomFileFromDir, AddRequestParameter, AllQualifyData, AllQualifyNext, AreaData, AreaID, AreaIDEncoded, AreaName, AreaNameEncoded, AreaNext, AreaScriptKey, AreaScriptNext, AreaTbl, AreaXML, Authenticate, AutoTitleData, AutoTitleID, AutoTitleNext, BankAccountInfo, BankChainName, BankChainNext, BanListMgr, BaseCharClassName, BaseCharClassNext, BehaviorData, BehaviorID, BehaviorNext, CatalogCatNext, CatalogItemNext, CatalogMobNext, ChannelBackLogNext, ChannelInfo, ChannelNext, CharClassData, CharClassID, CharClassName, CharClassNext, CheckAuthCode, CheckReqParm, ClanData, ClanGovernmentData, ClanGovernmentID, ClanGovernmentNext, ClanID, ClanNext, ClassRaceNext, CoffeeTableRows, CommandJournalInfo, CommandJournalNext, ComponentData, ComponentID, ComponentNext, ComponentPieceData, ComponentPieceID, ComponentPieceNext, ControlPanel, CrossBaseClassAbilities, CrossClassAbilities, DeityData, DeityID, DeityNext, ExitData, ExpertiseData, ExpertiseID, ExpertiseNext, FactionData, FactionID, FactionName, FactionNext, FileData, FileInfo, FileMgr, FileNext, ForumInfo, ForumJournalNext, HelpTopics, HolidayData, HolidayID, HolidayNext, HTTPclientIP, HTTPstatus, HTTPstatusInfo, ImageVerificationImage, INIModify, INIValue, IsAccountSystem, IsDisabled, IsExpirationSystem, ItemData, JournalFunction, JournalInfo, JournalMessageNext, JournalName, JournalNext, LevelNext, LevelNumber, LogViewer, MobData, MUDGrinder, MudInfo, MUDServerPort, MUDServerStatus, MUDServerVersion, NumPlayers, PlayerData, PlayerDelete, PlayerID, PlayerList, PlayerNext, PlayerOnline, PlayerPortrait, PollData, PollID, PollNext, PrideStat, QuestData, QuestMaker, QuestMgr, QuestNext, RaceCatNext, RaceClassNext, RaceData, RaceID, RaceName, RaceNext, RandomAreaTemplates, RebuildReferenceDocs, RequestParameter, RequestParametersEncoded, ResourceMgr, RoomData, RoomID, RoomName, RoomNext, SipletInterface, SocialData, SocialID, SocialNext, SocialTbl, StatRejuvCharts, SystemFunction, SystemInfo, ThinPlayerData, TimsItemTable, Unsubscribe, WebServerName, WebServerPort, WebServerVersion, WebSock

public class StdWebMacro
extends java.lang.Object
implements WebMacro


Constructor Summary
StdWebMacro()
           
 
Method Summary
protected  java.lang.String clearWebMacros(java.lang.String s)
           
protected  java.lang.String clearWebMacros(java.lang.StringBuffer s)
           
protected  java.lang.StringBuffer colorwebifyOnly(java.lang.StringBuffer s)
           
 int compareTo(CMObject o)
           
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
protected  byte[] getHTTPFileData(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String file)
           
protected  java.io.File grabFile(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String filename)
           
protected  java.lang.StringBuilder helpHelp(java.lang.String s)
           
protected  java.lang.StringBuilder helpHelp(java.lang.StringBuilder s)
           
protected  java.lang.StringBuilder helpHelp(java.lang.StringBuilder s, int limit)
           
protected  java.lang.String htmlIncomingFilter(java.lang.String buf)
           
protected  java.lang.StringBuffer htmlIncomingFilter(java.lang.StringBuffer buf)
           
protected  java.lang.String htmlOutgoingFilter(java.lang.String buf)
           
protected  java.lang.StringBuffer htmlOutgoingFilter(java.lang.StringBuffer buf)
           
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 boolean isAdminMacro()
          Whether this macro is restricted to the admin web server.
 boolean isAWebPath()
          Whether this macro substitutes as an aspect of the web path instead of a standard web macro.
 java.lang.String L(java.lang.String str, java.lang.String... xs)
           
 java.lang.String name()
          The public name of this macro
 CMObject newInstance()
          Returns a new instance of this class.
protected  PairSVector<java.lang.String,java.lang.String> parseOrderedParms(java.lang.String parm, boolean preserveCase)
           
protected  java.util.Map<java.lang.String,java.lang.String> parseParms(java.lang.String parm)
           
protected  java.util.Map<java.lang.String,java.lang.String> parseParms(java.lang.String parm, boolean preserveCase)
           
 boolean preferBinary()
          Whether the runMacro or runBinaryMacro executor should be called.
 byte[] runBinaryMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String parm, com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
          This method is executed only if this macro returns true for preferBinary().
 java.lang.String runMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String parm, com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
          This method is executed only if this macro returns false for preferBinary().
protected  java.lang.String safeIncomingfilter(java.lang.String buf)
           
protected  java.lang.StringBuffer webify(java.lang.StringBuffer s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StdWebMacro

public StdWebMacro()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

name

public java.lang.String name()
Description copied from interface: WebMacro
The public name of this macro

Specified by:
name in interface CMObject
Specified by:
name in interface WebMacro
Returns:
The public name of this macro
See Also:
Environmental.Name()

isAWebPath

public boolean isAWebPath()
Description copied from interface: WebMacro
Whether this macro substitutes as an aspect of the web path instead of a standard web macro. If true is returned, URLs such as: http://mydomain.com/mymacroname?firstparm=value&secondparm=value might succeeed

Specified by:
isAWebPath in interface WebMacro
Returns:
whether this is a wierd URL macro

preferBinary

public boolean preferBinary()
Description copied from interface: WebMacro
Whether the runMacro or runBinaryMacro executor should be called.

Specified by:
preferBinary in interface WebMacro
Returns:
whether the runBinaryMacro executor should be called instead of runMacro
See Also:
WebMacro.runBinaryMacro(HTTPRequest, String, HTTPResponse), WebMacro.runMacro(HTTPRequest, String, HTTPResponse)

isAdminMacro

public boolean isAdminMacro()
Description copied from interface: WebMacro
Whether this macro is restricted to the admin web server.

Specified by:
isAdminMacro in interface WebMacro
Returns:
true if the macro is restricted to the admin web server

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

runBinaryMacro

public byte[] runBinaryMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                             java.lang.String parm,
                             com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
                      throws HTTPServerException
Description copied from interface: WebMacro
This method is executed only if this macro returns true for preferBinary(). It will execute the macro and return its results as a binary byte array. The response object is used to set cookies and headers only. Any response body is in the return object. Since 99% of macros are only filling in an existing page, nothing will be done with that anyway, and is only important when isAWebPath return true.

Specified by:
runBinaryMacro in interface WebMacro
Parameters:
httpReq - the external requests object
parm - any parameter strings given to the macro
httpResp - the response, with headers
Returns:
the binary stream result of running this macro
Throws:
HTTPServerException - a http error to pass to the user
See Also:
WebMacro.preferBinary(), HTTPRequest

runMacro

public java.lang.String runMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                                 java.lang.String parm,
                                 com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
                          throws HTTPServerException
Description copied from interface: WebMacro
This method is executed only if this macro returns false for preferBinary(). It will execute the macro and return its results as a string, which is then substituted for the macro reference in the web page where the macro was found. The response object is used to set cookies and headers only. Any response body is in the return object. Since 99% of macros are only filling in an existing page, nothing will be done with that anyway, and is only important when isAWebPath return true.

Specified by:
runMacro in interface WebMacro
Parameters:
httpReq - the external requests object
parm - any parameter strings given to the macro
httpResp - the response, with headers
Returns:
the string result of running this macro
Throws:
HTTPServerException - a http error to pass to the user
See Also:
WebMacro.preferBinary(), HTTPRequest

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>

colorwebifyOnly

protected java.lang.StringBuffer colorwebifyOnly(java.lang.StringBuffer s)

webify

protected java.lang.StringBuffer webify(java.lang.StringBuffer s)

clearWebMacros

protected java.lang.String clearWebMacros(java.lang.String s)

clearWebMacros

protected java.lang.String clearWebMacros(java.lang.StringBuffer s)

helpHelp

protected java.lang.StringBuilder helpHelp(java.lang.StringBuilder s)

helpHelp

protected java.lang.StringBuilder helpHelp(java.lang.String s)

helpHelp

protected java.lang.StringBuilder helpHelp(java.lang.StringBuilder s,
                                           int limit)

parseOrderedParms

protected PairSVector<java.lang.String,java.lang.String> parseOrderedParms(java.lang.String parm,
                                                                           boolean preserveCase)

safeIncomingfilter

protected java.lang.String safeIncomingfilter(java.lang.String buf)

htmlIncomingFilter

protected java.lang.String htmlIncomingFilter(java.lang.String buf)

htmlIncomingFilter

protected java.lang.StringBuffer htmlIncomingFilter(java.lang.StringBuffer buf)

htmlOutgoingFilter

protected java.lang.String htmlOutgoingFilter(java.lang.String buf)

htmlOutgoingFilter

protected java.lang.StringBuffer htmlOutgoingFilter(java.lang.StringBuffer buf)

getHTTPFileData

protected byte[] getHTTPFileData(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                                 java.lang.String file)
                          throws com.planet_ink.coffee_web.http.HTTPException
Throws:
com.planet_ink.coffee_web.http.HTTPException

grabFile

protected java.io.File grabFile(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                                java.lang.String filename)

parseParms

protected java.util.Map<java.lang.String,java.lang.String> parseParms(java.lang.String parm)

parseParms

protected java.util.Map<java.lang.String,java.lang.String> parseParms(java.lang.String parm,
                                                                      boolean preserveCase)

L

public java.lang.String L(java.lang.String str,
                          java.lang.String... xs)