Canonicalizing mapping in a WeakHashMap

What a canonicalizing container is?
Maybe one that stores unique objects. Unique objects in the sense that their equivalence is only established via ==, not based on the state?
In the API for WeakHashMap :
" This class is intended primarily for use with key objects whose equals methods test for object identity using the == operator. Once such a key is discarded it can never be recreated, so it is impossible to do a lookup of that key in a WeakHashMap at some later time and be surprised that its entry has been removed. This class will work perfectly well with key objects whose equals methods are not based upon object identity, such as String instances. With such recreatable key objects, however, the automatic removal of WeakHashMap entries whose keys have been discarded may prove to be confusing."
What sort of confussion is this?
Only that the programmer may be expecting that a recreatable object could be still in the map after having been discarded and recreated?

I was trying to make sure which the confussion was
because I found strange that anybody could be
surprised by a WeakHashMap doing its job.A WeakHashMap has the potential to cause confusion in the unwary programmer, for example
WeakHashMap map = new WeakHashMap();
map.put("Key", "Value");
System.out.println(map.get("Key"));If garbage was collected between the put and get calls, the "Key" -> "Value" mapping may have been collected (There are no references to "Key", except in the internal string pool). Seeing the program print out a null for the map get request is non-intuitive, which is the most likely source of confusion.
But now I think that this is similar to the behaviour
of a WeakReference Object as well. So why not using an
array of WeakReference objects intead?The usual reason for choosing a map over an array is for speed performance.
"The containers library has a special Map to hold weak
references: the WeakHashMap. This class is designed to
make the creation of canonicalized mappings easier. In
such a mapping, you are saving storage by making only
one instance of a particular value. When the program
needs that value, it looks up the existing object in
the mapping and uses that (rather than creating one
from scratch)."
So we should save space by making only one instance of
a particular value. What would prompt us to make
several instances of a value ? Copies of the same
object I suppose, otherwise it should have said
several instances of a class.I think it meant (?) to mean 'only one instance of a particular value class.', since you can only put objects in a map.
From the last sentence
it is inferred if not using this technique we should
be creating the object each time is used. Why?I think you are improperly negating this. My interpretation of the last sentence is that this is one method for preventing recreating objects that are used more than once. There may be other methods for doing this, they simply aren't covered by the statement.
To answer the second question, it may be preferable to create an object in each place it is used if the object is mutable - if the object is shared between two threads, then its contents may be unexpectedly changed by the other thread, causing strange errors.
I can tell, however, a difference between using
WeakReference array and a WeakHashMap.
In the former the point is to use an object as long as
it is not memory shortage. In the latter the point is
a kind of unique relation between the key and the
value (this my guess at least), but if there wasn't
any outside references to the values the behaviour is
very similar to the former. Continuing with this
though, if there was outside references to the value,
our aim wouldn't be saving memory but a relation
between the key and the value that would come to an
end when memory shortage occurred. Any use for this
possible feature?The most appropriate use for this I have seen is in implementing a memory cache. As long as memory doesn't become tight, repeated requests run blindingly fast. Well, at least compared to some operations such as File I/O, if in the context of caching file contents in memory.
Enough from me.
-Troy

Similar Messages

  • Again same problem with quotes, but cant find a proper sol

    I've gone thru so many posts, but cud'nt really find a solution. someone please help me here. I have a single insert function, which does all inserts for many tables, so cant use ppdstmt.setString(1, "value").
    I am trying to insert some data into SQL server database(thru jdbc). The normal data works just fine, but if the user inserts some data which have quotation marks, then its throwing an error that is invalid character.
    ex: received ->enters correctly into db
    but
    rec'd -> unable to
    Insert into table(name) values('Oreilly'); //works fine
    Insert into table(name) values('O'reilly'); //throws an error, sql exception
    because the sql server is unable to find the matching quote. I would like to replace it with a ` or double quotes, but I am unable to replace it. I am not using a string to insert a value, I am using an Object. so I am unable to use any preparedStatement also(like ppdstmt.setString(1,"value"). Also I cant use replaceAll function, because, I am using jdk1.3. Is there any other way, I can replace ' with '' or `. The following is my code for inserting data.
    private void insert(String pQualifierName, String pTableName, Map pValueMap)
    m1Buffer.append("INSERT INTO ").append(QualifyTableName(pQualifierName, pTableName)).append(" (");
    m2Buffer.append(" VALUES (");
    // go over all values
    boolean isNotFirst = false;
    for (Iterator i = pValueMap.keySet().iterator(); i.hasNext();)
    if (isNotFirst)
    m1Buffer.append(", ");
    m2Buffer.append(", ");
    isNotFirst = true;
    String aColumnName = (String) i.next();
    // add the column name to the first part
    m1Buffer.append(aColumnName);
    // add a "?" to the second part, as well as adding the value to the parameter list
    if(pValueMap.get(aColumnName)!= null) {
    //aColumnName=aColumnName.replace( '\'', '`');
    m2Buffer.append("'");
    m2Buffer.append(pValueMap.get(aColumnName));
    m2Buffer.append("'");
    } else {
    m2Buffer.append(pValueMap.get(aColumnName)); //appends the value we entered
    m1Buffer.append(")");
    m2Buffer.append(")");
    protected void insert()
    verifyUnbacked();
    try
    StatementBuilder aBuilder = StatementBuilder.insertStatement(accessQualifierName(), accessTableName(), mUnbackedMap);
    Connection aConnection = ConnectionPool.getConnection();
    try
    PreparedStatement aPreparedStatement = aBuilder.generatePreparedStatement(aConnection);
    try
    aPreparedStatement.executeUpdate();
    Thanks

    Barun_guha,
    Thanks for your code, but the problem is pValueMap.get(aColumnName) is an Object and it cannot be initialized as a String .
    scsi-boy,
    I am attaching the 2 files related, StatementBuilder.java and AbstractEntity.java.
    Basically, the statementBuilder.java builds the SQL stmt and AbstractEntity.java does the update, delete and inserts(it has the PreparedStament). So could someone suggest me a solution based on this code.
    Thanks
    import firstpro.util.AbstractType;
    import java.sql.*;
    import java.util.*;
    public class StatementBuilder
    private static final StatementType SELECT = new StatementType("SELECT");
    private static final StatementType INSERT = new StatementType("INSERT");
    private static final StatementType IDENTITY = new StatementType("IDENTITY");
    private static final StatementType UPDATE = new StatementType("UPDATE");
    private static final StatementType DELETE = new StatementType("DELETE");
    * is true when the prepared statment can be set as "read-only" (i.e., a select of some kind).
    private boolean mIsReadOnly = false;
    * denotes what operation this statement represents.
    private StatementType mStatementType;
    * accumulates all the table names used in the statement.
    private List mTableList = new ArrayList();
    * holds the sequence of tables followed in join expressions.
    private LinkedList mTableStack = new LinkedList();
    * accumulates the table column names referenced in the statement.
    private Set mReferenceSet = new HashSet();
    * holds the column names used in the select result.
    private List mResultColumnList = new ArrayList();
    * is the first part of the generated SQL statement.
    private StringBuffer m1Buffer = new StringBuffer();
    * is the second part of the generated SQL statement.
    private StringBuffer m2Buffer = new StringBuffer();
    * holds the list of actual parameter values to substitute for the "?" symbols in the generated SQL.
    private List mParameterList = new ArrayList();
    * constructs an instance with the given type.
    * @param pStatementType
    private StatementBuilder(StatementType pStatementType)
    mStatementType = pStatementType;
    * creates a "select" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @param pResult
    * @return
    static StatementBuilder selectStatement(String pQualifierName, String pTableName, AbstractEntityCondition pCondition, AbstractEntityResult pResult)
    StatementBuilder aBuilder = new StatementBuilder(SELECT);
    aBuilder.select(pQualifierName, pTableName, pCondition, pResult);
    return aBuilder;
    * creates a "select distinct" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @param pResult
    * @return
    static StatementBuilder distinctStatement(String pQualifierName, String pTableName, AbstractEntityCondition pCondition, AbstractEntityResult pResult)
    StatementBuilder aBuilder = new StatementBuilder(SELECT);
    aBuilder.distinct(pQualifierName, pTableName, pCondition, pResult);
    return aBuilder;
    * creates a "select count(*)" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @return
    static StatementBuilder countStatement(String pQualifierName, String pTableName, AbstractEntityCondition pCondition)
    StatementBuilder aBuilder = new StatementBuilder(SELECT);
    aBuilder.count(pQualifierName, pTableName, pCondition);
    return aBuilder;
    * creates in "insert" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pValueMap
    * @return
    static StatementBuilder insertStatement(String pQualifierName, String pTableName, Map pValueMap)
    StatementBuilder aBuilder = new StatementBuilder(INSERT);
    aBuilder.insert(pQualifierName, pTableName, pValueMap);
    return aBuilder;
    * creates an "identity" statement (for retrieving the generated primary key from the DB after an insert).
    * @param pTypeName
    * @return
    static StatementBuilder identityStatement(String pTypeName)
    StatementBuilder aBuilder = new StatementBuilder(IDENTITY);
    aBuilder.identity(pTypeName);
    return aBuilder;
    * creates an "update" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pValueMap
    * @param pCondition
    * @return
    static StatementBuilder updateStatement(String pQualifierName, String pTableName, Map pValueMap, AbstractEntityCondition pCondition)
    StatementBuilder aBuilder = new StatementBuilder(UPDATE);
    aBuilder.update(pQualifierName, pTableName, pValueMap, pCondition);
    return aBuilder;
    * creates a "delete" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @return
    static StatementBuilder deleteStatement(String pQualifierName, String pTableName, AbstractEntityCondition pCondition)
    StatementBuilder aBuilder = new StatementBuilder(DELETE);
    aBuilder.delete(pQualifierName, pTableName, pCondition);
    return aBuilder;
    * emits a predicate of "true".
    void trueAlways()
    appendTrue();
    * emits a predicate of "false".
    void falseAlways()
    appendFalse();
    * emits a "join" predicate.
    * @param pColumnName
    * @param pQualifierName
    * @param pJoinedTableName
    * @param pJoinedColumnName
    * @param pCondition
    void join(String pColumnName, String pQualifierName, String pJoinedTableName, String pJoinedColumnName, AbstractEntityCondition pCondition)
    if (!SELECT.equals(mStatementType))
    throw new RuntimeException("Join only allowed in SELECT");
    appendOpening();
    appendColumn(pColumnName);
    appendEqualTo();
    pushTable(pQualifierName, pJoinedTableName);
    appendColumn(pJoinedColumnName);
    appendClosing();
    appendAnd();
    appendOpening();
    appendCondition(pCondition);
    appendClosing();
    popTable();
    * emits an "and" predicate.
    * @param pCondition1
    * @param pCondition2
    void and(AbstractEntityCondition pCondition1, AbstractEntityCondition pCondition2)
    appendOpening();
    appendCondition(pCondition1);
    appendClosing();
    appendAnd();
    appendOpening();
    appendCondition(pCondition2);
    appendClosing();
    * emits an "and" predicate.
    * @param pConditionArray
    void and(AbstractEntityCondition[] pConditionArray)
    if (0 == pConditionArray.length)
    appendTrue();
    else
    for (int i = 0; i < pConditionArray.length; i++)
    if (i != 0)
    appendAnd();
    appendOpening();
    appendCondition(pConditionArray);
    appendClosing();
    * emits an "or" predicate.
    * @param pCondition1
    * @param pCondition2
    void or(AbstractEntityCondition pCondition1, AbstractEntityCondition pCondition2)
    appendOpening();
    appendCondition(pCondition1);
    appendClosing();
    appendOr();
    appendOpening();
    appendCondition(pCondition2);
    appendClosing();
    * emits an "or" predicate.
    * @param pConditionArray
    void or(AbstractEntityCondition[] pConditionArray)
    if (0 == pConditionArray.length)
    appendFalse();
    else
    for (int i = 0; i < pConditionArray.length; i++)
    if (i != 0)
    appendOr();
    appendOpening();
    appendCondition(pConditionArray[i]);
    appendClosing();
    * emits a "not" predicate.
    * @param pCondition
    void not(AbstractEntityCondition pCondition)
    appendNot();
    appendOpening();
    appendCondition(pCondition);
    appendClosing();
    * emits an "is null" predicate.
    * @param pColumnName
    void isNull(String pColumnName)
    appendColumn(pColumnName);
    appendIsNull();
    * emits an "is not null" predicate.
    * @param pColumnName
    void isNotNull(String pColumnName)
    appendColumn(pColumnName);
    appendIsNotNull();
    * emits a "between" predicate.
    * @param pColumnName
    * @param pValue1
    * @param pValue2
    void isBetween(String pColumnName, Object pValue1, Object pValue2)
    appendColumn(pColumnName);
    appendBetween();
    appendValue(pValue1);
    appendAnd();
    appendValue(pValue2);
    * emits a case-insensitive "between" predicate.
    * @param pColumnName
    * @param pValue1
    * @param pValue2
    void isBetweenIgnoringCase(String pColumnName, Object pValue1, Object pValue2)
    appendColumnUpper(pColumnName);
    appendBetween();
    appendValueUpper(pValue1);
    appendAnd();
    appendValueUpper(pValue2);
    * emits a "like" predicate.
    * @param pColumnName
    * @param pValue
    void isLike(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendLike();
    appendValue(pValue);
    * emits a case-insensitive "like" predicate.
    * @param pColumnName
    * @param pValue
    void isLikeIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendLike();
    appendValueUpper(pValue);
    * emits an "equals" predicate.
    * @param pColumnName
    * @param pValue
    void isEqualTo(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendEqualTo();
    appendValue(pValue);
    * emits a case-insensitive "equals" predicate.
    * @param pColumnName
    * @param pValue
    void isEqualToIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendEqualTo();
    appendValueUpper(pValue);
    * emits an "unequals" predicate.
    * @param pColumnName
    * @param pValue
    void isNotEqualTo(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendNotEqualTo();
    appendValue(pValue);
    * emits a case-insensitive "unequals" predicate.
    * @param pColumnName
    * @param pValue
    void isNotEqualToIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendNotEqualTo();
    appendValueUpper(pValue);
    * emits a "less than" predicate.
    * @param pColumnName
    * @param pValue
    void isLessThan(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendLessThan();
    appendValue(pValue);
    * emits a case-insensitive "less than" predicate.
    * @param pColumnName
    * @param pValue
    void isLessThanIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendLessThan();
    appendValueUpper(pValue);
    * emits a "less than or equals" predicate.
    * @param pColumnName
    * @param pValue
    void isLessThanOrEqualTo(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendLessThanOrEqualTo();
    appendValue(pValue);
    * emits a case-insensitive "less than or equals" predicate.
    * @param pColumnName
    * @param pValue
    void isLessThanOrEqualToIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendLessThanOrEqualTo();
    appendValueUpper(pValue);
    * emits a "greater than" predicate.
    * @param pColumnName
    * @param pValue
    void isGreaterThan(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendGreaterThan();
    appendValue(pValue);
    * emits a case-insensitive "greater than" predicate.
    * @param pColumnName
    * @param pValue
    void isGreaterThanIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendGreaterThan();
    appendValueUpper(pValue);
    * emits a "greater than or equals" predicate.
    * @param pColumnName
    * @param pValue
    void isGreaterThanOrEqualTo(String pColumnName, Object pValue)
    appendColumn(pColumnName);
    appendGreaterThanOrEqualTo();
    appendValue(pValue);
    * emits a case-insensitive "greater than or equals" predicate.
    * @param pColumnName
    * @param pValue
    void isGreaterThanOrEqualToIgnoringCase(String pColumnName, Object pValue)
    appendColumnUpper(pColumnName);
    appendGreaterThanOrEqualTo();
    appendValueUpper(pValue);
    * builds a "select" statment.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @param pResult
    private void select(String pQualifierName, String pTableName, AbstractEntityCondition pCondition, AbstractEntityResult pResult)
    // this statment only reads from the DB
    mIsReadOnly = true;
    // initialize the table stack using the selected table
    // the first push will write " FROM ..."
    pushTable(pQualifierName, pTableName);
    // build SELECT
    StringBuffer sb = new StringBuffer();
    // go over all columns
    for (int i = 0; i < pResult.mColumnNameList.size(); i++)
    // first one has command, others separate with commas
    sb.append(i == 0 ? "SELECT DISTINCT TOP 100 " : ", ");
    // get column name reference
    String aQualifiedColumnName = QualifyColumnName((String) pResult.mColumnNameList.get(i));
    // append to the statment
    sb.append(aQualifiedColumnName);
    // add to the result list
    mResultColumnList.add(aQualifiedColumnName);
    sb.append(" ");
    // insert the "SELECT ..." before the " FROM ..." that was written on the push above
    m1Buffer.insert(0, sb);
    // do WHERE
    if (pCondition != null)
    m2Buffer.append(" WHERE ");
    // will add to both "FROM..." in first buffer and to "WHERE ..." in second buffer
    // this call does most of the hard work, and handles joins to other tables, etc.
    appendCondition(pCondition);
    // do ORDER BY
    for (int i = 0; i < pResult.mOrderByList.size(); i++)
    m2Buffer.append(i == 0 ? " ORDER BY " : ", ");
    // column name
    String aQualifiedColumnName = QualifyColumnName((String) pResult.mOrderByList.get(i));
    // direction (ASC or DESC)
    m2Buffer.append(aQualifiedColumnName).append(" ").append(pResult.mOrderByDirectionList.get(i));
    popTable();
    * is currently identical to "select"
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    * @param pResult
    private void distinct(String pQualifierName, String pTableName, AbstractEntityCondition pCondition, AbstractEntityResult pResult)
    select(pQualifierName, pTableName, pCondition, pResult);
    * builds a "count(*)" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    private void count(String pQualifierName, String pTableName, AbstractEntityCondition pCondition)
    // this statment only reads from the DB
    mIsReadOnly = true;
    // initialize the table stack using the selected table
    // the first push will write " FROM ..."
    pushTable(pQualifierName, pTableName);
    // build and insert "SELECT ..." before the " FROM ..." that was written on the push above
    m1Buffer.insert(0, "SELECT COUNT(*) ");
    // do WHERE
    if (pCondition != null)
    m2Buffer.append(" WHERE ");
    // will add to both "FROM..." in first buffer and to "WHERE ..." in second buffer
    // this call does most of the hard work, and handles joins to other tables, etc.
    appendCondition(pCondition);
    // finished with this table
    popTable();
    private void insert(String pQualifierName, String pTableName, Map pValueMap)
    // m1Buffer.append("set identity_insert " + pTableName + " off "+ " ").append("INSERT INTO ").append(QualifyTableName(pQualifierName, pTableName)).append(" (");
    m1Buffer.append("INSERT INTO ").append(QualifyTableName(pQualifierName, pTableName)).append(" (");
    m2Buffer.append(" VALUES (");
    // go over all values
    boolean isNotFirst = false;
    for (Iterator i = pValueMap.keySet().iterator(); i.hasNext();)
    if (isNotFirst)
    m1Buffer.append(", ");
    m2Buffer.append(", ");
    isNotFirst = true;
    String aColumnName = (String) i.next();
    // add the column name to the first part
    m1Buffer.append(aColumnName);
    // add a "?" to the second part, as well as adding the value to the parameter list
    if(pValueMap.get(aColumnName)!= null) {
    //Object column= pValueMap.get(aColumnName);
    aColumnName=aColumnName.replace( '\'', '`');
    m2Buffer.append("'");
    m2Buffer.append(pValueMap.get(aColumnName));
    m2Buffer.append("'");
    } else {
    m2Buffer.append(pValueMap.get(aColumnName));
    m1Buffer.append(")");
    m2Buffer.append(")");
    * builds a key-retrieval statement.
    //* @param pTypeName
    protected void identity(String pTypeName)
    m2Buffer.append("SELECT CAST( @@IDENTITY AS "+ pTypeName + ")" );
    private void update(String pQualifierName, String pTableName, Map pValueMap, AbstractEntityCondition pCondition)
    m1Buffer.append("UPDATE ").append(QualifyTableName(pQualifierName, pTableName)).append(" SET ");
    // go over all values
    boolean isNotFirst = false;
    for (Iterator i = pValueMap.keySet().iterator(); i.hasNext();)
    if (isNotFirst)
    m1Buffer.append(", ");
    isNotFirst = true;
    String aColumnName = (String) i.next();
    // add the column name to the first part
    m1Buffer.append(aColumnName);
    m1Buffer.append(" = ");
    // add a "?" to the second part, as well as adding the value to the parameter list
    if((pValueMap.get(aColumnName)) == null) {
    m1Buffer.append(pValueMap.get(aColumnName));
    // System.out.println("NUll values are= " + pValueMap.get(aColumnName));
    } else{
    m1Buffer.append("'");
    m1Buffer.append(pValueMap.get(aColumnName));
    m1Buffer.append("'");
    //System.out.println("Not Null values ARE*********" + pValueMap.get(aColumnName));
    // do WHERE
    if (pCondition != null)
    m2Buffer.append(" WHERE ");
    // this will normally be a key condition (one row updated at a time)
    appendCondition(pCondition); // will add to "WHERE ..." clause
    * builds a "delete" statement.
    * @param pQualifierName
    * @param pTableName
    * @param pCondition
    private void delete(String pQualifierName, String pTableName, AbstractEntityCondition pCondition)
    m1Buffer.append("DELETE FROM ").append(QualifyTableName(pQualifierName, pTableName));
    // do WHERE
    if (pCondition != null)
    m2Buffer.append(" WHERE ");
    // this will normally be a key condition (one row deleted at a time)
    appendCondition(pCondition); // will add to "WHERE ..." clause
    * will get and save a unique (to this statment) correlation name of the given table
    * to be used in the WHERE clause. This is in case the same table joined to
    * more than once in the same query.
    * @param pTableName
    * @return
    private String getCorrelationName(String pTableName)
    String aCorrelationName = pTableName;
    while (mReferenceSet.contains(aCorrelationName))
    aCorrelationName = aCorrelationName + "_OTHER";
    mReferenceSet.add(aCorrelationName);
    return aCorrelationName;
    * will prepend the qualifier (if any) to the table name.
    * @param pQualifierName
    * @param pTableName
    * @return
    private static String QualifyTableName(String pQualifierName, String pTableName)
    return (pQualifierName == null ? "" : pQualifierName + ".") + pTableName;
    * will make the given table the current table for parts of the expression below the current node.
    * This is used anytime a join is needed.
    * @param pQualifierName
    * @param pTableName
    private void pushTable(String pQualifierName, String pTableName)
    String aCorrelationName = getCorrelationName(pTableName);
    String aTableDeclaration = QualifyTableName(pQualifierName, pTableName) + " " + aCorrelationName;
    m1Buffer.append(m1Buffer.length() == 0 ? " FROM " : ", ");
    m1Buffer.append(aTableDeclaration);
    mTableList.add(aTableDeclaration);
    mTableStack.addFirst(aCorrelationName); // push
    * will revert to the previous current table. This is used after a join is finished building.
    private void popTable()
    mTableStack.removeFirst(); // pop
    * gets the table at the top of the stack.
    * @return
    private String getCurrentTable()
    return (String) mTableStack.getFirst();
    * will qualify the given column name with the name of the current table.
    * @param pColumnName
    * @return
    private String QualifyColumnName(String pColumnName)
    if (SELECT.equals(mStatementType))
    return getCurrentTable() + "." + pColumnName;
    return pColumnName;
    * will qualify the column name and append it to the second buffer.
    * @param pColumnName
    private void appendColumn(String pColumnName)
    m2Buffer.append(QualifyColumnName(pColumnName));
    * will qualify the column name and append it to the second buffer, adding the "UPPER" function.
    * @param pColumnName
    private void appendColumnUpper(String pColumnName)
    appendUpper();
    appendOpening();
    appendColumn(pColumnName);
    appendClosing();
    * will append "?" to the second buffer and add the value to the parameter list,
    * or append "NULL" if the value is null.
    * @param pValue
    private void appendValue(Object pValue)
    if (pValue == null)
    m2Buffer.append("NULL");
    else
    m2Buffer.append("?");
    mParameterList.add(pValue);
    * will append "?" to the second buffer and add the upper-cased value to the parameter list,
    * or append "NULL" if the value is null.
    * @param pValue
    private void appendValueUpper(Object pValue)
    appendValue(null == pValue ? null : pValue.toString().toUpperCase());
    * will append the condition to the statement. This initiates a series of calls that walks
    * the expression tree and builds the SQL accordingly by calls back to methods of this class.
    * @param pCondition
    private void appendCondition(AbstractEntityCondition pCondition)
    pCondition.buildPredicate(this);
    * appends a true condition.
    private void appendTrue()
    m2Buffer.append("1=1");
    * appends a false condition.
    private void appendFalse()
    m2Buffer.append("1=0");
    * appends an opening parenthesis.
    private void appendOpening()
    m2Buffer.append("(");
    * appends a closing parenthesis.
    private void appendClosing()
    m2Buffer.append(")");
    * appends "is null".
    private void appendIsNull()
    m2Buffer.append(" IS NULL");
    * appends "is not null".
    private void appendIsNotNull()
    m2Buffer.append(" IS NOT NULL");
    private void appendAnd()
    m2Buffer.append(" AND ");
    private void appendOr()
    m2Buffer.append(" OR ");
    private void appendNot()
    m2Buffer.append("NOT ");
    private void appendLike()
    m2Buffer.append(" LIKE ");
    private void appendBetween()
    m2Buffer.append(" BETWEEN ");
    private void appendEqualTo()
    m2Buffer.append(" = ");
    private void appendNotEqualTo()
    m2Buffer.append(" <> ");
    private void appendLessThan()
    m2Buffer.append(" < ");
    private void appendLessThanOrEqualTo()
    m2Buffer.append(" <= ");
    private void appendGreaterThan()
    m2Buffer.append(" > ");
    private void appendGreaterThanOrEqualTo()
    m2Buffer.append(" >= ");
    * appends the upper-casing function.
    private void appendUpper()
    m2Buffer.append("UCASE");
    * constructs the final SQL expression, builds a prepared statement with it,
    * and fills the prepared statement with the parameter values.
    * @param pConnection
    * @return
    * @throws SQLException
    PreparedStatement generatePreparedStatement(Connection pConnection) throws SQLException
    pConnection.setReadOnly(mIsReadOnly);
    String sql = m1Buffer + " " + m2Buffer;
    System.out.println("GENERATED SQL = ");
    System.out.println(sql);
    System.out.println("GENERATED SQL = ");
    System.out.println(sql);
    System.out.println("PARAMETER LIST = ");
    System.out.println(mParameterList);
    PreparedStatement aPreparedStatement = pConnection.prepareStatement(sql);
    for (int i = 0; i < mParameterList.size(); i++)
    aPreparedStatement.setObject(1 + i, mParameterList.get(i));
    return aPreparedStatement;
    * is an enumerated type.
    private static final class StatementType extends AbstractType
    private StatementType(String pType)
    super(pType);
    [i]package firstpro.persistence;
    import multnomah.database.ConnectionPool;
    import java.sql.*;
    import java.util.Date;
    import java.util.*;
    * is the abstract base class for all generated entity classes.
    * It encompasses all functionality not specifically tied to a given field.
    public abstract class AbstractEntity
    * contains all "open" entities in the system.
    * This is to insure that two threads cannot update the same entity at the same time.
    * It is a weak hash map, so that entries do not prevent garbage collection if something is left open.
    static Map sOpenEntityMap = new WeakHashMap();
    * is true when the entity represents a row in a table
    boolean mIsBacked = false;
    * is true when the entity is in a state that allows updating
    boolean mIsMutable = false;
    * contains the values that exist in the underlying row

  • Weak and concurrent hash map for caching

    Hello,
    I have written a very simple cache class with both weakness and concurrency benefits. This class is intended to be used as a weak cache in "hot redeploy" capable servers (JBoss or any other).
    My implementation uses the (problematic) "double-check" pattern with a reentrant lock and encapsulates a WeakHashMap with WeakReference values (to avoid circular key/value references). Here is the code:
    public interface ValueCreator<V> {
         public V create();
    public class WeakCache<K, V> {
         private final Lock lock = new ReentrantLock();
         private final Map<K, WeakReference<V>> weakMap;
         public WeakCache() {
              this(16);
         public WeakCache(int initialCapacity) {
              this(initialCapacity, 0.75F);
         public WeakCache(int initialCapacity, float loadFactor) {
              weakMap = new WeakHashMap<K, WeakReference<V>>(initialCapacity, loadFactor);
         public V get(K key, ValueCreator<V> creator) {
              WeakReference<V> ref = weakMap.get(key);
              if (ref == null) {
                   lock.lock();
                   try {
                        ref = weakMap.get(key);
                        if (ref == null) {
                             ref = new WeakReference<V>(creator.create());
                             weakMap.put(key, ref);
                   } finally {
                        lock.unlock();
              return ref.get();
         }One usage of this cache is for session ejb3 lookup:
    private static final WeakCache<Class, Object> LOOKUP_CACHE = new WeakCache<Class, Object>();
    public static <T> T lookup(final Class<T> serviceClass) {
         T service = (T)LOOKUP_CACHE.get(serviceClass,
              new ValueCreator<Object>() {
                   public T create() {
                        String lookup = "myapp/" + serviceClass.getSimpleName() + "/local";
                        try {
                             return (T)(new InitialContext()).lookup(lookup);
                        } catch (NamingException e) {
                             throw new RuntimeException("Could not lookup EJB " + serviceClass + ": " + lookup, e);
         return service;
    ...2 questions:
    1. Is there any issue with concurrent access to this cache ?
    2. What happens exactly when the garbage collector wants to free memory with a map with both weak keys and values ?
    Some limited tests show that the behavior of this cache fits my needs: the lookup cache is cleared on redeploy and it keeps its key/values pairs otherwise.
    Thanks for any comments.
    Message was edited by:
    fwolff999

    I know that DCL is broken under certain circumstances (but I have read it may work with modern JVM and the use of volatile variables for example).
    So: is it broken with this specific implementation and if so, what should be done to make it work ?
    The getter method is potentially setting a value (like in ConcurrentHashMap.putIfAbsent) and it uses a ValueCreator in order to actually create the value only if it is not already present in the map.

  • A Safe use of WeakHashMap ?

    Hi all,
    I'd like to have a clarification about WeakHashMap. It is stated that a WeakHashMap is a special implementation of the Map interface that references its keys via weak references. This allows the garbage collector to reclaim the key even though its still referenced by the hashmap.
    BUT since we don't have much control over the garbage collector...what could be a safe use of the WeakHashMap??? why would we need a component that could be "cleaned up" depending on arbitrary memory needs?? is there a way to prevent to GC to clean the WeakHashMap, let's say when I need to browse the collection and then release it?
    hope I was clear
    Thanks
    Francesco

    You can use the WeakHashMap to implement a cache. The important thing is that the keys must be re-creatable. An example:
    Say you have a component that operates on instances of the Foo class, and everything about the Foo instances is stored in a database, indexed on an ID number. There are millions of different Foo instances in the database. Applications that use your component refer to Foo objects by ID in all of your APIs.
    You don't want to cache every Foo instance in the whole database, because that would require too much memory. It's better to cache only the Foo instances that you're actually using, on the theory that if the calling application asks for the 12345 Foo once, it will probably ask for it again.
    So, you can use a WeakHashMap, which will allow the GC to reclaim keys only when the key is otherwise not in normal use, that is, when there are no strong references to the key. When the caller asks for Foo 12345, first you look in the WeakHashMap, and if there's no key 12345 in the WHM, then and only then do you take the performance hit of going to the database.
    A good article on the WeakHashMap by Jack Shirazi is here:
    http://www.onjava.com/pub/a/onjava/2001/07/09/optimization.html

  • WeakHashMap, cleanup and API level guarantees

    When does WeakHashMap groom/cleanup the entries i.e. remove the WeakReferences from the Map? It appears it does it when the WeakHashMap is accessed. In other words, if for some reason the WeakHashMap is NOT accessed, the entries continue to stay as WeakReferences.
    Is there an API level guarantee as to how the cleanup works? I do not see it documented in WeakHashMap API.
    A hashtable-based Map implementation with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector, that is, made finalizable, finalized, and then reclaimed. When a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently from other Map implementations.
    Again, if there is any reference on how and when this -- An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. -- happens, it will be useful.
    With regards,
    M.P. Ardhanareeswaran

    user514049 wrote:
    This is more than casual curiosity.
    WeakHashMap is actually working for me by "accident". In my case, I am storing some PhantomReferences in this Map as values (and not keys) for cleanup. There is a quiet period before the application is torn down during which there are no updates to the WeakHashMap. My application is able to retrieve the PhantomReferences at close time and clean them up.
    It appears that it is "not advisable" to rely on this behavior.Not sure exactly what you mean here. Are the keys referenced anywhere else, or only in the map? If only in the map, then the entries can be removed from the map and the keys GCed at any time. If you need to know that you'll have access to some entry at some point in your code, then you'll have to make sure that there's a reference to the key outside of the map.
    If "by accident" you mean that, so far, the entries are always there even without you maintaining other references to the keys, then, yes, that is just happenstance, and not to be relied on.
    To quote the third sentence of WHM's javadoc (emphasis mine): "More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector, that is, made finalizable, finalized, and then reclaimed."
    Edited by: jverd on Nov 11, 2011 12:46 PM

  • Remote System and Remote Key Mapping at a glance

    Hi,
    I want to discuss the concept of Remote System and Remote Key Mapping.
    Remote System is a logical system which is defined in MDM Console for a MDM Repository.
    We can define key mapping enabled at each table level.
    The key mapping is used to distinguish records at Data Manager after running the Data Import.
    Now 1 record can have 1 remote system with two different keys but two different records cannot have same remote system with same remote key. So, Remote key is an unique identifier for record for any remote system for each individual records.
    Now whenever we import data from a Remote System, the remote system and remote key are mapped for each individual records. Usually all records have different remote keys.
    Now, when syndicating back the record with default remote key is updated in the remote system that is sent by xml file format.
    If same record is updated two times from a same remote system, the remote key will be different and the record which is latest contains highest remote key.
    Now, I have to look at Data Syndication and Remote key.
    I have not done Data Syndication but my concept tell if there is duplicate record with same remote system but different remote keys both will be syndicated back. But if same record have two remote keys for same remote system then only the default remote key is syndicated back.
    Regards
    Kaushik Banerjee

    You are right Kaushik,
    I have not done Data Syndication but my concept tell if there is duplicate record with same remote system but different remote keys both will be syndicated back.
    Yes, but if they are duplicate, they needs to be merged.
    But if same record have two remote keys for same remote system then only the default remote key is syndicated back.
    This is after merging. So whichever remote key has tick mark in key mapping option(default) , it will be syndicated back.
    Pls refer to these links for better understanding.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/80eb6ea5-2a2f-2b10-f68e-bf735a45705f
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/7051c376-f939-2b10-7da1-c4f8f9eecc8c%0c
    Hope this helps,
    + An

  • Error while deleting a mapping

    Hi all,
    I am getting the following error while deleting a mapping. My client version is 10.2.0.4.36
    API5072: Internal Error: Null message for exception. Please contact Oracle Support with the stack trace and details on how to reproduce it.
    oracle.wh.util.Assert: API5072: Internal Error: Null message for exception. Please contact Oracle Support with the stack trace and details on how to reproduce it.
         at oracle.wh.util.Assert.owbAssert(Assert.java:51)
         at oracle.wh.ui.jcommon.OutputConfigure.showMsg(OutputConfigure.java:216)
         at oracle.wh.ui.common.CommonUtils.error(CommonUtils.java:370)
         at oracle.wh.ui.common.WhDeletion.doActualDel(WhDeletion.java:512)
         at oracle.wh.ui.common.WhDeletion.deleteObject(WhDeletion.java:203)
         at oracle.wh.ui.common.WhDeletion.deleteObject(WhDeletion.java:283)
         at oracle.wh.ui.jcommon.tree.WhTree.deleteItem(WhTree.java:346)
         at oracle.wh.ui.console.commands.DeleteCmd.performAction(DeleteCmd.java:50)
         at oracle.wh.ui.console.commands.TreeMenuHandler$1.run(TreeMenuHandler.java:188)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:189)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Thanks in advance!
    Sebastian

    These type of Internal Errors are all too common in OWB and it's difficult to diagnose the exact problem.
    I'd suggest closing the Design Centre, going back in and trying to delete it again, this will often resolve Internal errors.
    There's also an article on Metalink Doc ID: 460411.1 about errors when deleting mappings but it's specific to an ACLContainer error, so may or may not be of use.
    One of the suggestions is to connect as the Repository Owner rather than a User and try to delete the mapping.
    Cheers
    Si
    Edited by: ScoobySi on Sep 10, 2009 11:44 AM

  • FileName in ABAP XSLT Mapping

    Dear SDN,
    In an integration scenario we are using sender File Adapter and a  ABAP XSLT Mapping.
    Is there any way to get the source FileName from such mapping.  Im trying to use the adapter-specific message attributes, but it doesn't work, and I didn´t find an example, probably I and doing somthing wrong.
    regards,
    GP

    Thank you for your help,
    I just try to access the adapter-specific attibutes using:
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">
    <xsl:variable name="filename"  select="key:create('http://sap.com/xi/XI/System/File', 'Directory')" />
    </xsl:stylesheet>
    but the following error raised:
    <SAP:Stack>Error while calling mapping program YXSLT_TEST (type Abap-XSLT, kernel error ID CX_XSLT_RUNTIME_ERROR) Call of unknown function</SAP:Stack>
    have you had this situation?

  • Sample source code for fields mapping in expert routine

    Hi All
    Iam writing the expert routine from dso to cube for example I have two fields in dso FLD1,FLD2
    same fields in infocube also ,can any body provide me sample abap code to map source fields to target fields in expert routine,your help will be heighly appreciatble,it's an argent.
    regards
    eliaz

    Basic would be ;
    RESULT_FIELDS -xxx = <SOURCE_FIELDS> -xxx
    you have the source fields as source, and result fields for as the target. In between you can check some conditions as in other routines of transformation.
    BEGIN OF tys_SC_1, shows your source fields ( in your case DSO chars and key figures)
    BEGIN OF tys_TG_1, , shows your result fields ( in your case Cube characteristics)
    Hope this helps
    Derya

  • How can I distinguish different action mapping in one ActionClass file?

    I would like to create a ActionClass which will handle 3 mapping which comes from /add, /show or /del.
    My question is how can I change the code so that the ActionClass servlet can distinguish the request from different url mapping ? Can anyone give me some short hints? Thx.
    struts-config.xml
    <action-mappings>
    <action name="MemberInfoForm" path="/add" scope="request" type="com.myapp.real.MemberAction">
    <action name="MemberInfoForm" path="/show" scope="request" type="com.myapp.real.MemberAction">
    <action name="MemberInfoForm" path="/del" scope="request" type="com.myapp.real.MemberAction">
    </action-mappings>MemberAction.class
    public class MemberAction extends org.apache.struts.action.Action {
        private final static String SUCCESS = "success";
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            return mapping.findForward(SUCCESS);
    ...

    http://struts.apache.org/1.2.x/api/org/apache/struts/actions/MappingDispatchAction.html
    http://struts.apache.org/1.2.x/api/org/apache/struts/actions/DispatchAction.html
    Thank you so much for all of your suggestion.
    I read the document of MappingDispatchAction and its note say:
    NOTE - Unlike DispatchAction, mapping characteristics may differ between the various handlers, so you can combine actions in the same class that, for example, differ in their use of forms or validation.........
    I wonder in DispatchAction, we can also have various forms or validation as MappingDispatchAction does, just by using different name in the action tag, for example:
    <action input="/p1.jsp" name="MForm1" path="/member" scope="session" parameter="action" type="com.myapp.real.MemberAction">
    <action input="/p2.jsp" name="MForm2" path="/member" scope="session" parameter="action" type="com.myapp.real.MemberAction">
    <action input="/p3.jsp" name="MForm3" path="/member" scope="session" parameter="action" type="com.myapp.real.MemberAction">Hence, it is not the difference as stated from the NOTE, right?
    Edited by: roamer on Jan 22, 2008 10:32 AM

  • How can I save to the same map every time when printing pdfs?

    How can I save to the same map every time when printing pdfs?
    Finder points to the document map even when I chose a different map recently.
    I often print series of pdfs from the print dialog box, I'd like to choose the map to save to and then have all subsequent pdf prints automatically directed to the same map until I decide otherwise.

    that link seems to be broken right now:
    403 Error - Forbidden  - No cred, dude.

  • Sensor Mapping Express VI's performanc​e degrades over time

    I was attempting to do a 3d visualization of some sensor data. I made a model and managed to use it with the 3d Picture Tool Sensor Mapping Express VI. Initially, it appeared to work flawlessly and I began to augment the scene with further objects to enhance the user experience. Unfortunately, I believe I am doing something wrong at this stage. When I add the sensor map object to the other objects, something like a memory leak occurs. I begin to encounter performance degradation almost immediately.
    I am not sure how I should add to best add in the Sensor Map Object reference to the scene as an object. Normally, I establish these child relationships first, before doing anything to the objects, beyond creating, moving, and anchoring them. Since the Sensor Map output reference is only available AFTER the express vi run. My compromise solution, presently, is to have a case statement of controlled by the"First Call" constant. So far, performace seems to be much better.
    Does anyone have a better solution? Am I even handling these objects the way the community does it?
    EDIT: Included the vi and the stl files.
    Message Edited by Sean-user on 10-28-2009 04:12 PM
    Message Edited by Sean-user on 10-28-2009 04:12 PM
    Message Edited by Sean-user on 10-28-2009 04:16 PM
    Solved!
    Go to Solution.
    Attachments:
    test for forum.vi ‏105 KB
    chamber.zip ‏97 KB

    I agree with Hunter, your current solution is simple and effective, and I can't really visualize a much better way to accomplish the same task.
    Just as a side-note, the easiest and simplest way to force execution order is to use the error terminals on the functions and VIs in your block diagram. Here'a VI snippet with an example of that based on the VI you posted. (If you paste the image into your block diagram, you can make edits to the code)
    Since you expressed some interest in documentation related to 3D picture controls, I did some searching and found a few articles you might be interested in. There's nothing terribly complex, but these should be a good starting point. The first link is a URL to the search thread, so you can get an idea of where/what I'm searching.You'll get more hits if you search from ni.com rather than ni.com/support.
    http://search.ni.com/nisearch/app/main/p/q/3d%20pi​cture/
    Creating a 3D Scene with the 3D Picture Control
    Configuring a 3D Scene Window
    Using the 3D Picture Control 'Create Height Field VI' to convert a 2D image into a 3D textured heigh...
    Using Lighting and Fog Effects in 3d Picture Control
    3D Picture Control - Create a Moving Texture Using a Series of Images
    Changing Set Rotation and Background of 3D Picture Control
    Caleb Harris
    National Instruments | Mechanical Engineer | http://www.ni.com/support

  • Numbers/Address Book and Google Maps

    I would love to integrate my spreadsheet of addresses or my Address Book with Google Maps.
    Is this possible? Somehow?
    I take a lot of trips across the country and don't always know when I will be driving by my friends. But if I had a map I could glance at to see where they all are, I would know that I could schedule a lunch with a friend halfway or something like that.
    I have heard about MapPoint, but don't know if there is anything like this that is free/affordable/non-MS.
    Thanks!

    Integrating in Numbers would not be automatic. You'd have to format links to assign to each address.
    I've seen plug-ins to use Google maps with Address Book. Try a search on MacUpdate or VersionTracker for Address Book.
    I think one of the features for Address Book in Leopard is integration with Google maps.

  • Mapping/invoking key codes in a GameCanvas's main game loop.

    I'm trying to bind some diagonal sprite movement methods to the keypad. I already know that I have to map out the diagonals to key codes since key states only look out for key presses in the upper half of the phone (d-pad, soft buttons, etc...). Problem is, how do I invoke them in the main game loop since a key state can be encapsulated in a method and piped through the loop? What makes this even worst is a bug that my phone maker's game API (Siemens Game API for MIDP 1.0, which is their own implementation of the MIDP 2.0 Game API) has, in which if I override the keyPressed, keyReleased, or keyRepeated methods, it will always set my key states to zero, thus I can't move the sprite at all. Also, it seems that my phone's emulator automatically maps key states to 2, 4, 6, and 8, so my only concern is how do I map the diagonal methods into 1, 3, 7, and 9, as well as invoking them in the main game loop? Enclosed is the example code that I've been working on as well as the link to a thread in the Siemens (now Benq Mobile) developer's forum about the bug's discovery:
    http://agathonisi.erlm.siemens.de:8080/jive3/thread.jspa?forumID=6&threadID=15784&messageID=57992#57992
    the code:
    import com.siemens.mp.color_game.*;
    import javax.microedition.lcdui.*;
    public class ExampleGameCanvas extends GameCanvas implements Runnable {
    private boolean isPlay; // Game Loop runs when isPlay is true
    private long delay; // To give thread consistency
    private int currentX, currentY; // To hold current position of the 'X'
    private int width; // To hold screen width
    private int height; // To hold screen height
    // Sprites to be used
    private GreenThing playerSprite;
    private Sprite backgroundSprite;
    // Layer Manager
    private LayerManager layerManager;
    // Constructor and initialization
    public ExampleGameCanvas() throws Exception {
    super(true);
    width = getWidth();
    height = getHeight();
    currentX = width / 2;
    currentY = height / 2;
    delay = 20;
    // Load Images to Sprites
    Image playerImage = Image.createImage("/transparent.PNG");
    playerSprite = new GreenThing (playerImage,32,32,width,height);
    playerSprite.startPosition();
    Image backgroundImage = Image.createImage("/background2.PNG");
    backgroundSprite = new Sprite(backgroundImage);
    layerManager = new LayerManager();
    layerManager.append(playerSprite);
    layerManager.append(backgroundSprite);
    // Automatically start thread for game loop
    public void start() {
    isPlay = true;
    Thread t = new Thread(this);
    t.start();
    public void stop() { isPlay = false; }
    // Main Game Loop
    public void run() {
    Graphics g = getGraphics();
    while (isPlay == true) {
    input();
    drawScreen(g);
    try { Thread.sleep(delay); }
    catch (InterruptedException ie) {}
    //diagonalInput(diagonalGameAction);
    // Method to Handle User Inputs
    private void input() {
    int keyStates = getKeyStates();
    //playerSprite.setFrame(0);
    // Left
    if ((keyStates & LEFT_PRESSED) != 0) {
    playerSprite.moveLeft();
    // Right
    if ((keyStates & RIGHT_PRESSED) !=0 ) {
    playerSprite.moveRight();
    // Up
    if ((keyStates & UP_PRESSED) != 0) {
    playerSprite.moveUp();
    // Down
    if ((keyStates & DOWN_PRESSED) !=0) {
    playerSprite.moveDown();
    /*private void diagonalInput(int gameAction){
    //Up-left
    if (gameAction==KEY_NUM1){
    playerSprite.moveUpLeft();
    //Up-Right
    if (gameAction==KEY_NUM3){
    playerSprite.moveUpRight();
    //Down-Left
    if (gameAction==KEY_NUM7){
    playerSprite.moveDownLeft();
    //Down-Right
    if (gameAction==KEY_NUM9){
    playerSprite.moveDownRight();
    /*protected void keyPressed(int keyCode){
    int diagonalGameAction = getGameAction(keyCode);
    switch (diagonalGameAction)
    case GameCanvas.KEY_NUM1:
    if ((diagonalGameAction & KEY_NUM1) !=0)
    playerSprite.moveUpLeft();
    break;
    case GameCanvas.KEY_NUM3:
    if ((diagonalGameAction & KEY_NUM3) !=0)
    playerSprite.moveUpRight();
    break;
    case GameCanvas.KEY_NUM7:
    if ((diagonalGameAction & KEY_NUM7) !=0)
    playerSprite.moveDownLeft();
    break;
    case GameCanvas.KEY_NUM9:
    if ((diagonalGameAction & KEY_NUM9) !=0)
    playerSprite.moveDownRight();
    break;
    repaint();
    // Method to Display Graphics
    private void drawScreen(Graphics g) {
    //g.setColor(0x00C000);
    g.setColor(0xffffff);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(0x0000ff);
    // updating player sprite position
    //playerSprite.setPosition(currentX,currentY);
    // display all layers
    //layerManager.paint(g,0,0);
    layerManager.setViewWindow(0,0,101,80);
    layerManager.paint(g,0,0);
    flushGraphics();
    }EDIT: Also enclosed is a thread over in J2ME.org in which another user reports of the same flaw.
    http://www.j2me.org/yabbse/index.php?board=12;action=display;threadid=5068

    Okay...you lost me...I thought that's what I was doing?
    If you mean try hitTestPoint ala this:
    wally2.addEventListener(Event.ENTER_FRAME, letsSee);
    function letsSee(event:Event)
              // create a for loop to test each array item hitting wally...
              for (var i:Number=0; i<iceiceArray.length; i++)
                   // if you don't hit platform...
              if (wally2.hitTestPoint(iceiceArray[i].x, iceiceArray[i].y, false)) {
              wally2.y -= 5;}
                          return;
    That's not working either.

  • Key mapping Generator Tool

    Scenario
    One customer has two systems: System A and System B in his landscape. System A serves as the central server for item master data management. He maintains the same set of item master data in System B as that of System B manually. Now, the customer wants to use B1i to keep the item master data in System B automatically up to date as that in System A.
    Use this tools to create the keys in the Bizstore.
    Please read carefully the documentation before proceeding.
    Lot of success,
    Felipe

    Hi all,
    When running the tool I get an exception.
    I have created a csv with all the cardcodes in it that need to be pushed. I have uploaded the tool to B1i. I've supplied the parameters and when I click execute the thing throws an exception.
    Input path:
    D:\B1i\Tools\Mapping Tool\Extracted\B1i2005PL05 or PL06\Reference\Common_BP.csv
    Bizflow to execute:
    /com.sap.b1i.datasync.keymapping/bfd/KeyMappingGeneration.bfd
    Parameters: SenderSysId=0010000100,SenderObjectTypeId=B1.2005_BP,SenderKeyName=CardCode,SenderKeySelectionPath=BOM/BO/BusinessPartners/row/CardCode,ReceiverSysId=0010000102
    Exception:
    HTTP Status 500 - com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception: com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception: com.sap.b1i.bizprocessor.BizProcException: BPE001 Nested exception: com.sap.b1i.utilities.UtilException: UTE001 Nested exception: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:414) caused by: com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception: com.sap.b1i.bizprocessor.BizProcException: BPE001 Nested exception: com.sap.b1i.utilities.UtilException: UTE001 Nested exception: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:414) caused by: com.sap.b1i.bizprocessor.BizProcException: BPE001 Nested exception: com.sap.b1i.utilities.UtilException: UTE001 Nested exception: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:414) caused by: com.sap.b1i.utilities.UtilException: UTE001 Nested exception: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:414) caused by: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:414)
    What is wrong?
    Kind regards,
    Dwight

Maybe you are looking for

  • My Ipod Touch Shows Up Into Itunes, But I Can Click On It To Sync, Its Locked Or Something?

    Hi, i need Help, ever since i updated iTunes to the newest one i been having an issue, i plug in my ipod touch 5g and it shows up in itunes, but problem is i cant click on it, shows my device is plugged in but its locked or something and i cant open

  • How many songs can a 2GB nano hold?

    My daughter has an ipod mini that holds 1000 songs on it. Her mini and my sons ipod nano are on the same account so they share the same songs. My daughter has 265 songs total and was trying to update my sons nano. When she tryed it said that he didnt

  • MobileMe Galley Widget

    Used MobileMe Galley widget to show a movie, published and no problems. However, is there a way to delete or stop the download function button?

  • Function 3 key doesn't work on one account on iMac

    I am using an IMac and the F3 key works on my account, but doesn't work on my wife's account.  I checked the keyboard settings in preferences on both accounts, but i don't see any differences that would cause this to happen.  Does any one  have any s

  • How to avoid the prompt when verifing signature?

    I sign the doc with my cert. The cert is not trusted by Acrobat/Reader itself so when i try to verify the signature Acrobat/Reader will prompt the user cert is not trusted. My question is how to avoid this prompt through Acrobat SDK or how to add my