CreateItemRequest.java

Index Score
net.sourceforge.kolmafia.request
KoLmafia

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
CYCLOMATICCyclomatic complexity
COMPARISONSNumber of comparison operators
LINE_COMMENTNumber of line comments
LOCLines of code
OPERATORSNumber of operators
EXEC_COMMENTSComments in executable code
PROGRAM_LENGTHHalstead program length
LINESNumber of lines in the source file
SIZESize of the file in bytes
ELOCEffective lines of code
OPERANDSNumber of operands
LOGICAL_LINESNumber of statements
RETURNSNumber of return points from functions
BLOCKSNumber of blocks
WHITESPACENumber of whitespace lines
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
EXITSProcedure exits
INTERFACE_COMPLEXITYInterface complexity
LOOPSNumber of loops
JAVA0145JAVA0145 Tab character used in source file
JAVA0032JAVA0032 Switch statement missing default
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0034JAVA0034 Missing braces in if statement
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0179JAVA0179 Local variable hides visible field
UNIQUE_OPERATORSNumber of unique operators
JAVA0040JAVA0040 Switch statement contains N cases (maximum: M)
FUNCTIONSNumber of function declarations
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0126JAVA0126 Method declares unchecked exception in throws
COMMENTSComment lines
JAVA0173JAVA0173 Unused method parameter
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
/** * Copyright (c) 2005-2008, KoLmafia development team * http://kolmafia.sourceforge.net/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * [1] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * [2] Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * [3] Neither the name "KoLmafia" nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package net.sourceforge.kolmafia.request; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sourceforge.kolmafia.AdventureResult; import net.sourceforge.kolmafia.KoLAdventure; import net.sourceforge.kolmafia.KoLCharacter; import net.sourceforge.kolmafia.KoLConstants; import net.sourceforge.kolmafia.KoLmafia; import net.sourceforge.kolmafia.RequestLogger; import net.sourceforge.kolmafia.objectpool.ItemPool; import net.sourceforge.kolmafia.session.InventoryManager; import net.sourceforge.kolmafia.session.ResultProcessor; import net.sourceforge.kolmafia.utilities.StringUtilities; import net.sourceforge.kolmafia.persistence.ConcoctionDatabase; import net.sourceforge.kolmafia.persistence.ItemDatabase; import net.sourceforge.kolmafia.persistence.Preferences; public class CreateItemRequest extends GenericRequest implements Comparable { private static final GenericRequest REDIRECT_REQUEST = new GenericRequest( "inventory.php?action=message" ); private static final CreationRequestArray ALL_CREATIONS = new CreationRequestArray(); public static final Pattern ITEMID_PATTERN = Pattern.compile( "item\\d?=(\\d+)" ); public static final Pattern QUANTITY_PATTERN = Pattern.compile( "(quantity|qty)=(\\d+)" ); public AdventureResult createdItem; private String name; private int itemId, mixingMethod; private int beforeQuantity; private int yield; private int quantityNeeded, quantityPossible; private static final int[][] DOUGH_DATA = { // input, tool, output { ItemPool.DOUGH, ItemPool.ROLLING_PIN, ItemPool.FLAT_DOUGH }, { ItemPool.FLAT_DOUGH, ItemPool.UNROLLING_PIN, ItemPool.DOUGH } }; /** * Constructs a new <code>CreateItemRequest</code> with nothing known other than the form to use. This is used * by descendant classes to avoid weird type-casting problems, as it assumes that there is no known way for the item * to be created. * * @param formSource The form to be used for the item creation * @param itemId The item ID for the item to be handled */ public CreateItemRequest( final String formSource, final int itemId ) { this( formSource, itemId, KoLConstants.SUBCLASS ); } /** * Constructs a new <code>CreateItemRequest</code> where you create the given number of items. * * @param formSource The form to be used for the item creation * @param itemId The identifier for the item to be created * @param mixingMethod How the item is created * @param quantityNeeded How many of this item are needed */ private CreateItemRequest( final String formSource, final int itemId, final int mixingMethod ) { super( formSource ); this.addFormField( "pwd" ); this.itemId = itemId; this.name = ItemDatabase.getItemName( itemId ); this.yield = ConcoctionDatabase.getYield( itemId ); this.mixingMethod = mixingMethod; this.createdItem = new AdventureResult( itemId, yield ); } public void reconstructFields() { String formSource = ""; switch ( this.mixingMethod ) { case KoLConstants.COMBINE: formSource = KoLCharacter.inMuscleSign() ? "knoll.php" : "combine.php"; break; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: formSource = "cocktail.php"; break; case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: formSource = "cook.php"; break; case KoLConstants.SMITH: formSource = KoLCharacter.inMuscleSign() ? "knoll.php" : "smith.php"; break; case KoLConstants.SMITH_ARMOR: case KoLConstants.SMITH_WEAPON: formSource = "smith.php"; break; case KoLConstants.JEWELRY: case KoLConstants.EXPENSIVE_JEWELRY: formSource = "jewelry.php"; break; case KoLConstants.ROLLING_PIN: formSource = "inv_use.php"; break; case KoLConstants.CATALYST: case KoLConstants.CREATE_VIA_USE: formSource = "multiuse.php"; break; case KoLConstants.WOK: case KoLConstants.MALUS: case KoLConstants.STILL_MIXER: case KoLConstants.STILL_BOOZE: formSource = "guild.php"; break; case KoLConstants.CRIMBO07: formSource = "crimbo07.php"; break; } this.constructURLString( formSource ); this.addFormField( "pwd" ); if ( KoLCharacter.inMuscleSign() && this.mixingMethod == KoLConstants.SMITH ) { this.addFormField( "action", "smith" ); } else if ( this.mixingMethod == KoLConstants.CREATE_VIA_USE || this.mixingMethod == KoLConstants.CATALYST ) { this.addFormField( "action", "useitem" ); } else if ( this.mixingMethod == KoLConstants.STILL_BOOZE ) { this.addFormField( "action", "stillbooze" ); } else if ( this.mixingMethod == KoLConstants.STILL_MIXER ) { this.addFormField( "action", "stillfruit" ); } else if ( this.mixingMethod == KoLConstants.WOK ) { this.addFormField( "action", "wokcook" ); } else if ( this.mixingMethod == KoLConstants.MALUS ) { this.addFormField( "action", "malussmash" ); } else if ( this.mixingMethod == KoLConstants.CRIMBO07 ) { this.addFormField( "action", "toys" ); } else if ( this.mixingMethod != KoLConstants.SUBCLASS ) { this.addFormField( "action", "combine" ); } } public static final CreateItemRequest getInstance( final AdventureResult item ) { CreateItemRequest ir = CreateItemRequest.getInstance( item.getItemId(), true ); if ( ir == null ) { return null; } ir.setQuantityNeeded( item.getCount() ); return ir; } public static final CreateItemRequest getInstance( final int itemId ) { return CreateItemRequest.getInstance( itemId, true ); } public static final CreateItemRequest getInstance( final int itemId, final boolean returnNullIfNotPermitted ) { CreateItemRequest instance = CreateItemRequest.ALL_CREATIONS.get( itemId ); // Assume if you have subclass that everything // works as intended. if ( instance == null || instance.mixingMethod == KoLConstants.SUBCLASS ) { return instance; } // If the item creation process is not permitted, // then return null to indicate that it is not // possible to create the item. if ( returnNullIfNotPermitted ) { if ( !ConcoctionDatabase.isPermittedMethod( instance.mixingMethod ) ) { return null; } } return instance; } public static final CreateItemRequest constructInstance( final int itemId ) { if ( itemId == ItemPool.MEAT_PASTE || itemId == ItemPool.MEAT_STACK || itemId == ItemPool.DENSE_STACK ) { return new CombineMeatRequest( itemId ); } int mixingMethod = ConcoctionDatabase.getMixingMethod( itemId ); // Otherwise, return the appropriate subclass of // item which will be created. switch ( mixingMethod ) { case KoLConstants.COMBINE: return new CreateItemRequest( KoLCharacter.inMuscleSign() ? "knoll.php" : "combine.php", itemId, mixingMethod ); case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: return new CreateItemRequest( "cocktail.php", itemId, mixingMethod ); case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: return new CreateItemRequest( "cook.php", itemId, mixingMethod ); case KoLConstants.SMITH: return new CreateItemRequest( KoLCharacter.inMuscleSign() ? "knoll.php" : "smith.php", itemId, mixingMethod ); case KoLConstants.SMITH_ARMOR: case KoLConstants.SMITH_WEAPON: return new CreateItemRequest( "smith.php", itemId, mixingMethod ); case KoLConstants.JEWELRY: case KoLConstants.EXPENSIVE_JEWELRY: return new CreateItemRequest( "jewelry.php", itemId, mixingMethod ); case KoLConstants.ROLLING_PIN: return new CreateItemRequest( "inv_use.php", itemId, mixingMethod ); case KoLConstants.STARCHART: return new StarChartRequest( itemId ); case KoLConstants.PIXEL: return new PixelRequest( itemId ); case KoLConstants.GNOME_TINKER: return new GnomeTinkerRequest( itemId ); case KoLConstants.CRIMBO05: return new Crimbo05Request( itemId ); case KoLConstants.CATALYST: case KoLConstants.CREATE_VIA_USE: return new CreateItemRequest( "multiuse.php", itemId, mixingMethod ); case KoLConstants.WOK: case KoLConstants.MALUS: case KoLConstants.STILL_MIXER: case KoLConstants.STILL_BOOZE: return new CreateItemRequest( "guild.php", itemId, mixingMethod ); case KoLConstants.CRIMBO06: return new Crimbo06Request( itemId ); case KoLConstants.STAFF: return new ChefStaffRequest( itemId ); case KoLConstants.MULTI_USE: return new MultiUseRequest( itemId ); case KoLConstants.SINGLE_USE: return new SingleUseRequest( itemId ); case KoLConstants.CRIMBO07: return new Crimbo07Request( itemId ); default: return null; } } public boolean equals( final Object o ) { return o != null && o instanceof CreateItemRequest && this.itemId == ( (CreateItemRequest) o ).itemId; } public int compareTo( final Object o ) { return o == null ? -1 : this.getName().compareToIgnoreCase( ( (CreateItemRequest) o ).getName() ); } /** * Runs the item creation request. Note that if another item needs to be created for the request to succeed, this * method will fail. */ public void run() { if ( !KoLmafia.permitsContinue() || this.quantityNeeded <= 0 ) { return; } // Validate the ingredients once for the item // creation process. if ( this.mixingMethod != KoLConstants.SUBCLASS && this.mixingMethod != KoLConstants.ROLLING_PIN ) { if ( !this.makeIngredients() ) { return; } } int createdQuantity = 0; do { if ( !this.autoRepairBoxServant() ) { KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "Auto-repair was unsuccessful." ); return; } this.reconstructFields(); this.beforeQuantity = this.createdItem.getCount( KoLConstants.inventory ); switch ( this.mixingMethod ) { case KoLConstants.SUBCLASS: super.run(); if ( this.responseCode == 302 && this.redirectLocation.startsWith( "inventory" ) ) { CreateItemRequest.REDIRECT_REQUEST.constructURLString( this.redirectLocation ).run(); } break; case KoLConstants.ROLLING_PIN: this.makeDough(); break; default: this.combineItems(); break; } // Figure out how many items were created createdQuantity = this.createdItem.getCount( KoLConstants.inventory ) - this.beforeQuantity; // If we created none, set error state so iteration stops. if ( createdQuantity == 0 ) { // If the subclass didn't detect the failure, // do so here. if ( KoLmafia.permitsContinue() ) { KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "Creation failed, no results detected." ); } return; } KoLmafia.updateDisplay( "Successfully created " + this.getName() + " (" + createdQuantity + ")" ); this.quantityNeeded -= createdQuantity; } while ( this.quantityNeeded > 0 && KoLmafia.permitsContinue() ); } public void makeDough() { int input = -1; int tool = -1; int output = -1; // Find the array row and load the // correct tool/input/output data. for ( int i = 0; i < CreateItemRequest.DOUGH_DATA.length; ++i ) { output = CreateItemRequest.DOUGH_DATA[ i ][ 2 ]; if ( this.itemId == output ) { tool = CreateItemRequest.DOUGH_DATA[ i ][ 1 ]; input = CreateItemRequest.DOUGH_DATA[ i ][ 0 ]; break; } } if ( tool == -1 ) { KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "Can't deduce correct tool to use." ); return; } if ( !InventoryManager.retrieveItem( input, this.quantityNeeded ) ) { return; } // If we don't have the correct tool, and the // person wishes to create more than 10 dough, // then notify the person that they should // purchase a tool before continuing. if ( ( this.quantityNeeded >= 10 || InventoryManager.hasItem( tool ) ) && !InventoryManager.retrieveItem( tool ) ) { KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "Please purchase a " + ItemDatabase.getItemName( tool ) + " first." ); return; } // If we have the correct tool, use it to // create the needed dough type. if ( InventoryManager.hasItem( tool ) ) { KoLmafia.updateDisplay( "Using " + ItemDatabase.getItemName( tool ) + "..." ); new UseItemRequest( ItemPool.get( tool, 1 ) ).run(); return; } // Without the right tool, we must manipulate // the dough by hand. String name = ItemDatabase.getItemName( output ); UseItemRequest request = new UseItemRequest( ItemPool.get( input, 1 ) ); for ( int i = 1; KoLmafia.permitsContinue() && i <= this.quantityNeeded; ++i ) { KoLmafia.updateDisplay( "Creating " + name + " (" + i + " of " + this.quantityNeeded + ")..." ); request.run(); } } /** * Helper routine which actually does the item combination. */ private void combineItems() { AdventureResult[] ingredients = ConcoctionDatabase.getIngredients( this.itemId ); if ( ingredients.length == 1 || this.mixingMethod == KoLConstants.CREATE_VIA_USE || this.mixingMethod == KoLConstants.CATALYST || this.mixingMethod == KoLConstants.WOK ) { if ( this.getAdventuresUsed() > KoLCharacter.getAdventuresLeft() ) { KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "Ran out of adventures." ); return; } // If there is only one ingredient, then it probably // only needs a "whichitem" field added to the request. this.addFormField( "whichitem", String.valueOf( ingredients[ 0 ].getItemId() ) ); } else { // Check to make sure that the box servant is available // for this combine step. This is extra overhead when // no box servant is needed, but for easy readability, // the test always occurs. for ( int i = 0; i < ingredients.length; ++i ) { this.addFormField( "item" + ( i + 1 ), String.valueOf( ingredients[ i ].getItemId() ) ); } } int quantity = ( this.quantityNeeded + this.yield - 1 ) / this.yield; this.addFormField( "quantity", String.valueOf( quantity ) ); KoLmafia.updateDisplay( "Creating " + this.name + " (" + this.quantityNeeded + ")..." ); super.run(); } public void processResults() { int createdQuantity = this.createdItem.getCount( KoLConstants.inventory ) - this.beforeQuantity; // Check to see if box-servant was overworked and exploded. if ( this.responseText.indexOf( "Smoke" ) != -1 ) { KoLmafia.updateDisplay( "Your box servant has escaped!" ); switch ( this.mixingMethod ) { case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: KoLCharacter.setChef( false ); break; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: KoLCharacter.setBartender( false ); break; } } // Because an explosion might have occurred, the // quantity that has changed might not be accurate. // Therefore, update with the actual value. if ( createdQuantity >= this.quantityNeeded ) { return; } int undoAmount = this.quantityNeeded - createdQuantity; undoAmount = ( undoAmount + this.yield - 1 ) / this.yield; AdventureResult[] ingredients = ConcoctionDatabase.getIngredients( this.itemId ); for ( int i = 0; i < ingredients.length; ++i ) { ResultProcessor.processItem( ingredients[ i ].getItemId(), undoAmount * ingredients[ i ].getCount() ); } switch ( this.mixingMethod ) { case KoLConstants.COMBINE: if ( !KoLCharacter.inMuscleSign() ) { ResultProcessor.processItem( ItemPool.MEAT_PASTE, undoAmount ); } break; case KoLConstants.SMITH: if ( !KoLCharacter.inMuscleSign() ) { ResultProcessor.processResult( new AdventureResult( AdventureResult.ADV, 0 - undoAmount ) ); } break; case KoLConstants.SMITH_WEAPON: case KoLConstants.SMITH_ARMOR: case KoLConstants.WOK: ResultProcessor.processResult( new AdventureResult( AdventureResult.ADV, 0 - undoAmount ) ); break; case KoLConstants.JEWELRY: case KoLConstants.EXPENSIVE_JEWELRY: ResultProcessor.processResult( new AdventureResult( AdventureResult.ADV, 0 - 3 * undoAmount ) ); break; case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: if ( !KoLCharacter.hasChef() ) { ResultProcessor.processResult( new AdventureResult( AdventureResult.ADV, 0 - undoAmount ) ); } break; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: if ( !KoLCharacter.hasBartender() ) { ResultProcessor.processResult( new AdventureResult( AdventureResult.ADV, 0 - undoAmount ) ); } break; default: break; } } private boolean autoRepairBoxServant() { if ( KoLmafia.refusesContinue() ) { return false; } // If we are not cooking or mixing, or if we already have the // appropriate servant installed, we don't need to repair switch ( this.mixingMethod ) { case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: if ( KoLCharacter.hasChef() ) { return true; } break; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: if ( KoLCharacter.hasBartender() ) { return true; } break; case KoLConstants.SMITH: return KoLCharacter.inMuscleSign() || InventoryManager.retrieveItem( ItemPool.TENDER_HAMMER ); case KoLConstants.SMITH_WEAPON: case KoLConstants.SMITH_ARMOR: return InventoryManager.retrieveItem( ItemPool.TENDER_HAMMER ); default: return true; } boolean autoRepairSuccessful = false; // If they do want to auto-repair, make sure that // the appropriate item is available in their inventory switch ( this.mixingMethod ) { case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: autoRepairSuccessful = this.useBoxServant( ItemPool.CHEF, ItemPool.CLOCKWORK_CHEF,ItemPool.BAKE_OVEN ); break; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: autoRepairSuccessful = this.useBoxServant( ItemPool.BARTENDER, ItemPool.CLOCKWORK_BARTENDER, ItemPool.COCKTAIL_KIT ); break; } return autoRepairSuccessful && KoLmafia.permitsContinue(); } private boolean retrieveNoServantItem( final int noServantItem ) { return !Preferences.getBoolean( "requireBoxServants" ) && KoLCharacter.getAdventuresLeft() > 0 && InventoryManager.retrieveItem( noServantItem ); } private boolean useBoxServant( final int servant, final int clockworkServant, final int noServantItem ) { if ( !Preferences.getBoolean( "autoRepairBoxServants" ) ) { return this.retrieveNoServantItem( noServantItem ); } // First, check to see if a box servant is available // for usage, either normally, or through some form // of creation. int usedServant = -1; if ( InventoryManager.hasItem( clockworkServant, false ) ) { usedServant = clockworkServant; } else if ( InventoryManager.hasItem( servant, true ) ) { usedServant = servant; } if ( usedServant == -1 ) { if ( KoLCharacter.canInteract() && ( Preferences.getBoolean( "autoSatisfyWithMall" ) || Preferences.getBoolean( "autoSatisfyWithStash" ) ) ) { usedServant = servant; } else { return this.retrieveNoServantItem( noServantItem ); } } // Once you hit this point, you're guaranteed to // have the servant in your inventory, so attempt // to repair the box servant. new UseItemRequest( ItemPool.get( usedServant, 1 ) ).run(); return servant == ItemPool.CHEF ? KoLCharacter.hasChef() : KoLCharacter.hasBartender(); } public boolean makeIngredients() { KoLmafia.updateDisplay( "Verifying ingredients for " + this.name + " (" + this.quantityNeeded + ")..." ); boolean foundAllIngredients = true; // If this is a combining request, you need meat paste as well. if ( this.mixingMethod == KoLConstants.COMBINE && !KoLCharacter.inMuscleSign() ) { int pasteNeeded = ConcoctionDatabase.getMeatPasteRequired( this.itemId, this.quantityNeeded ); AdventureResult paste = ItemPool.get( ItemPool.MEAT_PASTE, pasteNeeded ); if ( !InventoryManager.retrieveItem( paste ) ) { foundAllIngredients = false; } } AdventureResult[] ingredients = ConcoctionDatabase.getIngredients( this.itemId ); int yield = ConcoctionDatabase.getYield( this.itemId ); for ( int i = 0; i < ingredients.length; ++i ) { // First, calculate the multiplier that's needed // for this ingredient to avoid not making enough // intermediate ingredients and getting an error. int multiplier = 0; for ( int j = 0; j < ingredients.length; ++j ) { if ( ingredients[ i ].getItemId() == ingredients[ j ].getItemId() ) { multiplier += ingredients[ i ].getCount(); } } // Then, make enough of the ingredient in order // to proceed with the concoction. int quantity = this.quantityNeeded * multiplier; if ( yield > 1 ) { quantity = ( quantity + yield - 1 ) / yield; } if ( !InventoryManager.retrieveItem( ingredients[ i ].getItemId(), quantity ) ) { foundAllIngredients = false; } } return foundAllIngredients; } /** * Returns the item Id for the item created by this request. * * @return The item Id of the item being created */ public int getItemId() { return this.itemId; } /** * Returns the name of the item created by this request. * * @return The name of the item being created */ public String getName() { return ItemDatabase.getItemName( this.itemId ); } /** * Returns the quantity of items to be created by this request if it were to run right now. */ public int getQuantityNeeded() { return this.quantityNeeded; } /** * Sets the quantity of items to be created by this request. This method is used whenever the original quantity * intended by the request changes. */ public void setQuantityNeeded( final int quantityNeeded ) { this.quantityNeeded = quantityNeeded; } /** * Returns the quantity of items to be created by this request if it were to run right now. */ public int getQuantityPossible() { return this.quantityPossible; } /** * Sets the quantity of items to be created by this request. This method is used whenever the original quantity * intended by the request changes. */ public void setQuantityPossible( final int quantityPossible ) { this.quantityPossible = quantityPossible; } /** * Returns the string form of this item creation request. This displays the item name, and the amount that will be * created by this request. * * @return The string form of this request */ public String toString() { return this.getName() + " (" + this.getQuantityPossible() + ")"; } /** * An alternative method to doing adventure calculation is determining how many adventures are used by the given * request, and subtract them after the request is done. * * @return The number of adventures used by this request. */ public int getAdventuresUsed() { switch ( this.mixingMethod ) { case KoLConstants.SMITH: return KoLCharacter.inMuscleSign() ? 0 : this.quantityNeeded; case KoLConstants.SMITH_ARMOR: case KoLConstants.SMITH_WEAPON: return this.quantityNeeded; case KoLConstants.JEWELRY: case KoLConstants.EXPENSIVE_JEWELRY: return 3 * this.quantityNeeded; case KoLConstants.COOK: case KoLConstants.COOK_REAGENT: case KoLConstants.SUPER_REAGENT: case KoLConstants.COOK_PASTA: return KoLCharacter.hasChef() ? 0 : this.quantityNeeded; case KoLConstants.MIX: case KoLConstants.MIX_SPECIAL: case KoLConstants.MIX_SUPER: return KoLCharacter.hasBartender() ? 0 : this.quantityNeeded; case KoLConstants.WOK: return this.quantityNeeded; } return 0; } public static final boolean registerRequest( final boolean isExternal, final String urlString ) { // First, delegate subclasses, if it's a subclass request. if ( urlString.startsWith( "starchart.php" ) ) { return StarChartRequest.registerRequest( urlString ); } if ( urlString.startsWith( "mystic.php" ) ) { return PixelRequest.registerRequest( urlString ); } if ( urlString.startsWith( "crimbo07.php" ) ) { return Crimbo07Request.registerRequest( urlString ); } if ( urlString.indexOf( "action=makestaff" ) != -1 ) { return ChefStaffRequest.registerRequest( urlString ); } if ( urlString.indexOf( "action=makepaste" ) != -1 ) { return CombineMeatRequest.registerRequest( urlString ); } if ( urlString.startsWith( "inv_use.php" ) ) { if ( SingleUseRequest.registerRequest( urlString ) ) { return true; } String tool = ""; String ingredient = ""; if ( urlString.indexOf( "whichitem=873" ) != -1 ) { // Rolling Pin tool = "rolling pin"; ingredient = "wad of dough"; } if ( urlString.indexOf( "whichitem=874" ) != -1 ) { // Unrolling Pin tool = "unrolling pin"; ingredient = "flat dough"; } else { return false; } AdventureResult item = new AdventureResult( ingredient, 1 ); int quantity = item.getCount( KoLConstants.inventory ); ResultProcessor.processItem( item.getItemId(), 0 - quantity ); RequestLogger.updateSessionLog(); RequestLogger.updateSessionLog( "Use " + tool ); return true; } if ( urlString.startsWith( "multiuse.php" ) ) { if ( MultiUseRequest.registerRequest( urlString ) ) { return true; } int quantity = 1; String method = "Use "; int item1 = -1; int item2 = -1; if ( urlString.indexOf( "whichitem=24" ) != -1 ) { // Ten-leaf clover item1 = ItemPool.TEN_LEAF_CLOVER; } else if ( urlString.indexOf( "whichitem=196" ) != -1 ) { // Disassembled clover item1 = ItemPool.DISASSEMBLED_CLOVER; } else if ( urlString.indexOf( "whichitem=1605" ) != -1 ) { // Delectable Catalyst method = "Mix "; item1 = ItemPool.CATALYST; item2 = ItemPool.REAGENT; } else { return false; } Matcher quantityMatcher = CreateItemRequest.QUANTITY_PATTERN.matcher( urlString ); if ( quantityMatcher.find() ) { quantity = StringUtilities.parseInt( quantityMatcher.group( 2 ) ); } StringBuffer command = new StringBuffer(); command.append( method ); command.append( quantity ); command.append( " " ); command.append( ItemDatabase.getItemName( item1 ) ); ResultProcessor.processItem( item1, 0 - quantity ); if ( item2 != -1 ) { command.append( " + " ); command.append( ItemDatabase.getItemName( item2 ) ); ResultProcessor.processItem( item2, 0 - quantity ); } RequestLogger.updateSessionLog(); RequestLogger.updateSessionLog( command.toString() ); return true; } // Now that we know it's not a special subclass instance, // all we do is parse out the ingredients which were used // and then print the attempt to the screen. int multiplier = 1; boolean usesTurns = false; boolean isCreationURL = false; StringBuffer command = new StringBuffer(); if ( urlString.startsWith( "combine.php" ) || urlString.startsWith( "knoll.php" ) && urlString.indexOf( "action=combine" ) != -1 ) { isCreationURL = true; command.append( "Combine " ); } else if ( urlString.startsWith( "cocktail.php" ) ) { isCreationURL = true; command.append( "Mix " ); usesTurns = !KoLCharacter.hasBartender(); } else if ( urlString.startsWith( "cook.php" ) ) { isCreationURL = true; command.append( "Cook " ); usesTurns = !KoLCharacter.hasChef(); } else if ( urlString.startsWith( "smith.php" ) && urlString.indexOf( "action=pulverize" ) != -1 ) { return false; } else if ( urlString.startsWith( "smith.php" ) || urlString.startsWith( "knoll.php" ) && urlString.indexOf( "action=smith" ) != -1 ) { isCreationURL = true; command.append( "Smith " ); usesTurns = true; } else if ( urlString.startsWith( "jewelry.php" ) ) { isCreationURL = true; command.append( "Ply " ); usesTurns = true; } else if ( urlString.indexOf( "action=stillbooze" ) != -1 || urlString.indexOf( "action=stillfruit" ) != -1 ) { isCreationURL = true; command.append( "Distill " ); usesTurns = false; } else if ( urlString.startsWith( "gnomes.php" ) ) { isCreationURL = true; command.append( "Tinker " ); usesTurns = false; } else if ( urlString.indexOf( "action=wokcook" ) != -1 ) { isCreationURL = true; command.append( "Wok " ); usesTurns = true; } else if ( urlString.indexOf( "action=malussmash" ) != -1 ) { isCreationURL = true; command.append( "Pulverize " ); usesTurns = false; multiplier = 5; } if ( !isCreationURL ) { return false; } Matcher itemMatcher = CreateItemRequest.ITEMID_PATTERN.matcher( urlString ); Matcher quantityMatcher = CreateItemRequest.QUANTITY_PATTERN.matcher( urlString ); boolean needsPlus = false; int quantity = quantityMatcher.find() ? StringUtilities.parseInt( quantityMatcher.group( 2 ) ) : 1; if ( urlString.indexOf( "makemax=on" ) != -1 ) { quantity = Integer.MAX_VALUE; while ( itemMatcher.find() ) { int itemId = StringUtilities.parseInt( itemMatcher.group( 1 ) ); AdventureResult item = new AdventureResult( itemId, 1 ); quantity = Math.min( item.getCount( KoLConstants.inventory ), quantity ); } itemMatcher = CreateItemRequest.ITEMID_PATTERN.matcher( urlString ); } quantity *= multiplier; if ( urlString.indexOf( "action=stillbooze" ) != -1 || urlString.indexOf( "action=stillfruit" ) != -1 ) { KoLCharacter.decrementStillsAvailable( quantity ); } while ( itemMatcher.find() ) { if ( needsPlus ) { command.append( " + " ); } int itemId = StringUtilities.parseInt( itemMatcher.group( 1 ) ); String name = ItemDatabase.getItemName( itemId ); if ( name == null ) { continue; } command.append( quantity ); command.append( ' ' ); command.append( name ); ResultProcessor.processItem( itemId, 0 - quantity ); needsPlus = true; } if ( urlString.startsWith( "combine.php" ) ) { ResultProcessor.processItem( ItemPool.MEAT_PASTE, 0 - quantity ); } else if ( urlString.indexOf( "action=wokcook" ) != -1 ) { command.append( " + " ); command.append( quantity ); command.append( " dry noodles" ); ResultProcessor.processItem( ItemPool.DRY_NOODLES, 0 - quantity ); command.append( " + " ); command.append( quantity ); command.append( " MSG" ); ResultProcessor.processItem( ItemPool.MSG, 0 - quantity ); } if ( usesTurns ) { command.insert( 0, "[" + ( KoLAdventure.getAdventureCount() + 1 ) + "] " ); } RequestLogger.updateSessionLog(); RequestLogger.updateSessionLog( command.toString() ); return true; } private static class CreationRequestArray { private final ArrayList internalList = new ArrayList(); public CreateItemRequest get( final int index ) { if ( index < 0 ) { return null; } for ( int i = this.internalList.size(); i <= index; ++i ) { this.internalList.add( CreateItemRequest.constructInstance( i ) ); } return (CreateItemRequest) this.internalList.get( index ); } public void set( final int index, final CreateItemRequest value ) { for ( int i = this.internalList.size(); i <= index; ++i ) { this.internalList.add( CreateItemRequest.constructInstance( i ) ); } this.internalList.set( index, value ); } public int size() { return this.internalList.size(); } } }

The table below shows all metrics for CreateItemRequest.java.

MetricValueDescription
BLOCKS125.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS150.00Comment lines
COMMENT_DENSITY 0.25Comment density
COMPARISONS144.00Number of comparison operators
CYCLOMATIC268.00Cyclomatic complexity
DECL_COMMENTS13.00Comments in declarations
DOC_COMMENT91.00Number of javadoc comment lines
ELOC590.00Effective lines of code
EXEC_COMMENTS30.00Comments in executable code
EXITS78.00Procedure exits
FUNCTIONS29.00Number of function declarations
HALSTEAD_DIFFICULTY126.68Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY112.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 1.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 4.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 1.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 1.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 2.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 2.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 3.00JAVA0116 Missing javadoc: field 'field'
JAVA011711.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 1.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 5.00JAVA0144 Line exceeds maximum M characters
JAVA01452247.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 2.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 2.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 3.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1238.00Number of lines in the source file
LINE_COMMENT59.00Number of line comments
LOC861.00Lines of code
LOGICAL_LINES354.00Number of statements
LOOPS11.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1649.00Number of operands
OPERATORS3395.00Number of operators
PARAMS23.00Number of formal parameter declarations
PROGRAM_LENGTH5044.00Halstead program length
PROGRAM_VOCAB443.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS89.00Number of return points from functions
SIZE34606.00Size of the file in bytes
UNIQUE_OPERANDS384.00Number of unique operands
UNIQUE_OPERATORS59.00Number of unique operators
WHITESPACE227.00Number of whitespace lines