Beispiel #1
0
 /* return string representation of fault code */
 public static String GetFaultString(long fault) {
   if (fault > 0L) {
     StringBuffer sb = new StringBuffer();
     if ((fault & TYPE_MASK) == TYPE_J1708) {
       // SID: "128/s123/1"
       // PID: "128/123/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int mid = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       if (!active) {
         sb.append("[");
       }
       sb.append(mid); // MID
       sb.append("/");
       if (DTOBDFault.IsJ1708_SID(fault)) {
         int sid = DTOBDFault.DecodePidSid(fault);
         sb.append("s").append(sid); // SID "128/s123/1"
       } else {
         int pid = DTOBDFault.DecodePidSid(fault);
         sb.append(pid); // PID "128/123/1"
       }
       sb.append("/");
       sb.append(fmi); // FMI
       if (!active) {
         sb.append("]");
       }
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_J1939) {
       // SPN: "128/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int spn = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       sb.append(spn); // SPN
       sb.append("/");
       sb.append(fmi); // FMI
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
       // DTC: "P0071" [was "024C"]
       boolean active = DTOBDFault.DecodeActive(fault);
       int sysChar = DTOBDFault.DecodeSystem(fault); // System: powertrain
       int subSys = DTOBDFault.DecodeSPID(fault); // Mfg/Subsystem/Problem
       if (Character.isLetter((char) sysChar)) {
         sb.append((char) sysChar);
       } else {
         sb.append("U");
       }
       if ((subSys & 0x8000) != 0) {
         sb.append("1");
       } else {
         sb.append("0");
       }
       String subSysStr = String.valueOf(1000 + ((subSys & 0xFFF) % 1000));
       sb.append(subSysStr.substring(1));
       return sb.toString();
     } else {
       // unrecognized
     }
   }
   return "";
 }
Beispiel #2
0
  /**
   * @param section
   * @param index
   * @return
   * @throws IOException
   */
  final String getStringFromSection(final Section section, final int index) throws IOException {
    if (index > section.getSize()) {
      return "";
    }

    final StringBuffer str = new StringBuffer();
    // Most string symbols will be less than 50 bytes in size
    final byte[] tmp = new byte[50];

    this.efile.seek(section.getFileOffset() + index);
    while (true) {
      int len = this.efile.read(tmp);
      for (int i = 0; i < len; i++) {
        if (tmp[i] == 0) {
          len = 0;
          break;
        }
        str.append((char) tmp[i]);
      }
      if (len <= 0) {
        break;
      }
    }

    return str.toString();
  }
Beispiel #3
0
 String concate(String[] strings) {
   StringBuffer buffer = new StringBuffer("");
   for (String string : strings) {
     buffer.append(string);
   }
   return buffer.toString();
 }
Beispiel #4
0
 public static String GetPropertyString(long fault) {
   StringBuffer sb = new StringBuffer();
   if ((fault & TYPE_MASK) == TYPE_J1708) {
     int mid = DecodeSystem(fault);
     int fmi = DecodeFMI(fault);
     int count = DecodeCount(fault);
     boolean active = DecodeActive(fault);
     sb.append(PROP_TYPE[0]).append("=").append(NAME_J1708);
     sb.append(" ");
     sb.append(PROP_MIL[0]).append("=").append(active ? "1" : "0");
     sb.append(" ");
     sb.append(PROP_MID[0]).append("=").append(mid);
     if (DTOBDFault.IsJ1708_SID(fault)) {
       int sid = DecodePidSid(fault);
       sb.append(" ");
       sb.append(PROP_SID[0]).append("=").append(sid);
     } else {
       int pid = DecodePidSid(fault);
       sb.append(" ");
       sb.append(PROP_PID[0]).append("=").append(pid);
     }
     sb.append(" ").append(PROP_FMI[0]).append("=").append(fmi);
     if (count > 1) {
       sb.append(" ");
       sb.append(PROP_COUNT[0]).append("=" + count);
     }
     if (!active) {
       sb.append(" ");
       sb.append(PROP_ACTIVE[0]).append("=false");
     }
   } else if ((fault & TYPE_MASK) == TYPE_J1939) {
     int spn = DecodeSystem(fault);
     int fmi = DecodeFMI(fault);
     int count = DecodeCount(fault);
     boolean active = true;
     sb.append(PROP_TYPE[0]).append("=").append(NAME_J1939);
     sb.append(" ");
     sb.append(PROP_MIL[0]).append("=").append(active ? "1" : "0");
     sb.append(" ");
     sb.append(PROP_SPN[0]).append("=").append(spn);
     sb.append(" ");
     sb.append(PROP_FMI[0]).append("=").append(DecodeFMI(fault));
     if (count > 1) {
       sb.append(" ");
       sb.append(PROP_COUNT[0]).append("=" + count);
     }
     if (!active) {
       sb.append(" ");
       sb.append(PROP_ACTIVE[0]).append("=false");
     }
   } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
     String dtc = DTOBDFault.GetFaultString(fault); // Powertrain
     sb.append(GetPropertyString_OBDII(new String[] {dtc}));
   } else {
     // unrecognized/empty
     sb.append(PROP_MIL[0]).append("=").append("0");
   }
   return sb.toString();
 }
Beispiel #5
0
 /**
  * @param s
  * @return
  */
 public static String mask(final String s) {
   final StringBuffer buffer = new StringBuffer(25);
   final int count = (s != null ? s.length() : 0);
   for (int n = 0; n < count; n++) {
     buffer.append('*');
   }
   return buffer.toString();
 }
Beispiel #6
0
 /**
  * ** A String reperesentation of this URI (with arguments) ** @param includeBlankValues True to
  * include keys for blank values. ** @return A String representation of this URI
  */
 public String toString(boolean includeBlankValues) {
   StringBuffer sb = new StringBuffer(this.getURI());
   if (!ListTools.isEmpty(this.getKeyValList())) {
     sb.append("?");
     this.getArgString(sb, includeBlankValues);
   }
   return sb.toString();
 }
Beispiel #7
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   if (this.hasValue()) {
     sb.append("=").append(this.val);
   }
   return sb.toString();
 }
Beispiel #8
0
 /**
  * ** A String reperesentation of this URI (with arguments) ** @return A String representation of
  * this URI
  */
 public String toString() {
   StringBuffer sb = new StringBuffer(this.getURI());
   if (!ListTools.isEmpty(this.getKeyValList())) {
     sb.append("?");
     this.getArgString(sb);
   }
   return sb.toString();
 }
Beispiel #9
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   String v = this.val;
   if ((v != null) && !v.equals("")) {
     sb.append("=").append(v);
   }
   return sb.toString();
 }
Beispiel #10
0
 public static String PrintList(ArrayList l) {
   StringBuffer sb = new StringBuffer("[ ");
   Iterator i = l.iterator();
   while (i.hasNext()) {
     Double d = (Double) i.next();
     sb.append(MDP._df.format(d.doubleValue()) + " ");
   }
   sb.append("]");
   return sb.toString();
 }
Beispiel #11
0
 public String nextString() throws Exception {
   StringBuffer sb = new StringBuffer("");
   byte c = read();
   while (c <= ' ') c = read();
   do {
     sb.append((char) c);
     c = read();
   } while (c > ' ');
   return sb.toString();
 }
 private String bigIntToHexString(BigInteger bi) {
   StringBuffer buf = new StringBuffer();
   buf.append("0x");
   String val = bi.toString(16);
   for (int i = 0; i < ((2 * addressSize) - val.length()); i++) {
     buf.append('0');
   }
   buf.append(val);
   return buf.toString();
 }
Beispiel #13
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.isHiRes() ? "H" : "L");
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getType());
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getIndex());
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getLength());
   return sb.toString();
 }
Beispiel #14
0
 /**
  * String Representation
  *
  * @return info
  */
 @Override
 public String toString() {
   StringBuffer sb = new StringBuffer("MGoal[");
   sb.append(get_ID())
       .append("-")
       .append(getName())
       .append(",")
       .append(getGoalPerformance())
       .append("]");
   return sb.toString();
 } //	toString
Beispiel #15
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.getAccountID());
   sb.append("/");
   sb.append(this.getDeviceID());
   sb.append(" ");
   sb.append(this.getStatusCode());
   sb.append("[");
   sb.append(this.getDescription());
   sb.append("]");
   return sb.toString();
 }
Beispiel #16
0
 public static String PrintState(ArrayList state) {
   StringBuffer sb = new StringBuffer();
   Iterator i = state.iterator();
   while (i.hasNext()) {
     Object o = i.next();
     if (o instanceof Boolean) {
       Boolean val = (Boolean) o;
       sb.append((val.booleanValue() ? "." : "X"));
     }
   }
   return sb.toString();
 }
Beispiel #17
0
 public static String GetPropertyString_OBDII(String dtcStr) {
   StringBuffer sb = new StringBuffer();
   sb.append(PROP_TYPE[0]).append("=").append(NAME_OBDII);
   sb.append(" ");
   if (!StringTools.isBlank(dtcStr)) {
     sb.append(PROP_MIL[0]).append("=").append("1");
     sb.append(" ");
     sb.append(PROP_DTC[0]).append("=").append(dtcStr);
   } else {
     sb.append(PROP_MIL[0]).append("=").append("0");
   }
   return sb.toString();
 }
Beispiel #18
0
 /**
  * Method 'display'
  *
  * @param dto
  */
 public static void display(City dto) {
   StringBuffer buf = new StringBuffer();
   buf.append(dto.getCityCode());
   buf.append(", ");
   buf.append(dto.getName());
   buf.append(", ");
   buf.append(dto.getCreatedBy());
   buf.append(", ");
   buf.append(dto.getCreatedDate());
   buf.append(", ");
   buf.append(dto.getUpdatedBy());
   buf.append(", ");
   buf.append(dto.getUpdatedDate());
   System.out.println(buf.toString());
 }
Beispiel #19
0
 /** @param args the command line arguments */
 public static void main(String[] args) {
   // TODO code application logic here
   try {
     Parserdoubt p = new Parserdoubt(System.in);
     int t = p.nextInt();
     StringBuffer sb = new StringBuffer();
     while (t-- > 0) {
       int a = p.nextInt();
       int b = p.nextInt();
       int c = p.nextInt();
       sb.append(find(a, b, c) + "\n");
     }
     System.out.print(sb.toString());
   } catch (Exception e) {
   }
 }
Beispiel #20
0
	/**
	 * 
	 * @创建人: yinxm
	 * @时间 : 2014-05-13 11:52:23 
	 * @功能 : TODO 	4、获取修改支付日志的sql
	 * @param	EcPayLog
	 * @return String 		
	 */
	public String getPayResultUpdateSql(EcPayLog ecPayLog){	//修改PAY_FLAG,和PAY_SEQ,和Note。根据orgCode和最大日志号LogId和coNum查找
		StringBuffer sb = new StringBuffer();
        sb.append("UPDATE EC_PAY_LOG SET ");
		sb.append(" PAY_FLAG='").append(ecPayLog.getPayFlag()).append("'");  //支付标志
		sb.append(", PAY_SEQ='").append(ecPayLog.getPaySeq()).append("'");	//银行支付流水号
		sb.append(", NOTE='").append(ecPayLog.getNote()).append("'");
    	sb.append(" WHERE ORG_CODE='").append(ecPayLog.getOrgCode()).append("'"); //公司编号
    	sb.append(" AND ");
    	sb.append("LOG_ID=");  //日志编号
    	sb.append("(SELECT MAX(LOG_ID)");//取最大号
    	sb.append(" FROM EC_PAY_LOG");
    	sb.append(" WHERE ORG_CODE='").append(ecPayLog.getOrgCode()).append("'");
    	sb.append(" AND CO_NUM='").append(ecPayLog.getCoNum()).append("'");
//    	sb.append(" AND PAY_FLAG='2'");
    	sb.append(" AND BANK_ID='").append(ecPayLog.getBankId()).append("'");
    	sb.append(")");
		return sb.toString();
	}
 private InputStream getReport(
     HttpServletRequest request,
     HttpServletResponse response,
     Tab tab,
     TableModel tableModel,
     Integer columnCountLimit)
     throws ServletException, IOException {
   StringBuffer suri = new StringBuffer();
   suri.append("/xava/jasperReport");
   suri.append("?language=");
   suri.append(Locales.getCurrent().getLanguage());
   suri.append("&widths=");
   suri.append(Arrays.toString(getWidths(tableModel)));
   if (columnCountLimit != null) {
     suri.append("&columnCountLimit=");
     suri.append(columnCountLimit);
   }
   response.setCharacterEncoding(XSystem.getEncoding());
   return Servlets.getURIAsStream(request, response, suri.toString());
 }
 /**
  * Gets the instances of <CODE>Template</CODE> that have an ID that is already in the database.
  *
  * @return An <CODE>ArrayList</CODE> containing the instances of <CODE>Template</CODE> already in
  *     the database.
  * @throws java.sql.SQLException Thrown on sql exception.
  */
 public ArrayList findTemplatesInDatabase() throws java.sql.SQLException {
   ArrayList templatesInDatabase = new ArrayList();
   Connection oracleConnection = getDataSource().getConnection();
   try {
     Statement query = oracleConnection.createStatement();
     try {
       StringBuffer sql = new StringBuffer("SELECT TMPL_ID FROM ");
       sql.append(MPSBrowserView.SCHEMA);
       sql.append(".TEMPLATE WHERE TMPL_ID IN (");
       ArrayList templates = getTemplates();
       int templateCount = templates.size();
       for (int i = 0; i < templateCount; i++) {
         if (i > 0) sql.append(", ");
         sql.append("'");
         sql.append(((Template) templates.get(i)).getID());
         sql.append("'");
       }
       sql.append(")");
       ResultSet result = query.executeQuery(sql.toString());
       try {
         while (result.next()) {
           String templateID = result.getString("TMPL_ID");
           for (int i = 0; i < templateCount; i++) {
             Template currentTemplate = (Template) templates.get(i);
             if (templateID.equals(currentTemplate.getID())) {
               templatesInDatabase.add(currentTemplate);
               currentTemplate.setInDatabase(true);
             }
           }
         }
       } finally {
         result.close();
       }
     } finally {
       query.close();
     }
   } finally {
     oracleConnection.close();
   }
   return templatesInDatabase;
 }
Beispiel #23
0
  /** Access is incapable of executing the following correctly with DISTINCTS on count columns */
  public String sqlString() {
    StringBuffer stringB = new StringBuffer();
    if (isCount) {
      stringB.append("SELECT ");
      stringB.append("COUNT(*) ");
    } else {
      if (sqlSelectStringB.length() > 0) {
        stringB.append("SELECT ");
        if (isDistinct) stringB.append("DISTINCT ");
        stringB.append(sqlSelectStringB.toString());
        stringB.append(" ");
      }
      ;
    }

    stringB.append("FROM ");
    stringB.append(sqlExtentStringB.toString());
    if (sqlQueryStringB.length() > 0) {
      stringB.append("WHERE ");
      stringB.append(sqlQueryStringB.toString());
    }
    ;
    return stringB.toString();
  }
 public String toString() {
   StringBuffer sb = new StringBuffer("X_GL_JournalBatch[").append(getID()).append("]");
   return sb.toString();
 }
Beispiel #25
0
 public String toString() {
   StringBuffer sb = new StringBuffer("X_MPC_Schedule[").append(getID()).append("]");
   return sb.toString();
 }
Beispiel #26
0
 /**
  * ** Decodes the specified hex-encoded argument (not yet fully tested) ** @param s The String to
  * decode ** @return The decoded String
  */
 private String decodeArg(String s) {
   StringBuffer sb = URIArg.decodeArg(null, s);
   return sb.toString();
 }
Beispiel #27
0
 /**
  * ** Hex-encodes a URL argument ** @param s The URL argument to encode ** @param obfuscateAll
  * True to force hex-encoding on all argument characters ** @return The hex-encoded String
  */
 private String encodeArg(String s, boolean obfuscateAll) {
   StringBuffer sb = URIArg.encodeArg(null, s, obfuscateAll);
   return sb.toString();
 }
Beispiel #28
0
  /**
   * Modifies the DO within its table. Performs recursive commit/delete on referenced DOs; all
   * operations occur within a single transaction to allow rollback in the event of error. Only the
   * creator of the transaction releases it.
   *
   * @param dbt The transaction object to use for this operation.
   * @param delete True if doing a delete, otherwise doing insert/update.
   * @exception com.lutris.appserver.server.sql.DatabaseManagerException if a Transaction can not be
   *     created.
   * @exception com.lutris.appserver.server.sql.DBRowUpdateException if a version error occurs.
   * @exception RefAssertionException thrown by okTo method.
   * @exception java.sql.SQLException if any SQL errors occur.
   */
  protected void modifyDO(DBTransaction dbt, boolean delete)
      throws SQLException, DatabaseManagerException, DataObjectException, RefAssertionException,
          DBRowUpdateException, QueryException {
    if (delete) okToDelete();
    else okToCommit();
    boolean ownTransaction = false;
    try {
      if (null == dbt) {
        DatabaseManager dbm = Enhydra.getDatabaseManager();
        dbt = dbm.createTransaction(); // create a transaction
        ownTransaction = true;
      }
      if (null == dbt)
        throw new DatabaseManagerException("DatabaseManager.createTransaction returned null.");
      if (delete) {
        // Code to perform cascading deletes is generated here
        // if cascading deletes are not supported by the database.

        // The following line keeps the compiler happy
        // when the CASCADING_DELETES tag is empty.
        if (false) throw new QueryException("XXX");
      } else {
        // commit referenced DOs.
        jobmatch.data.ProfileDO Profile_DO = getProfile();
        if (null != Profile_DO) {
          if (Profile_DO.isLoaded()) {
            okToCommitProfile(Profile_DO);
            Profile_DO.commit(dbt);
          } else {
            // since the referenced DO is not loaded,
            // it cannot be dirty, so there is no need to commit it.
          }
        } else {
          if (!false)
            throw new RefAssertionException(
                "Cannot commit TreeLeafDO ( "
                    + toString()
                    + " ) because Profile is not allowed to be null.");
        }
      }
      if (false) {
        // This throw is here to keep the compiler happy
        // in the case of a DO that does not refer to other DOs.
        // In that case, the above delete/commit code blocks will be empty
        // and throw nothing.
        throw new DataObjectException("foo");
      }
      if (delete) {
        dbt.delete(this);
      } else {
        if (isLoaded()) dbt.insert(this); // dbt.insert() handles insertions and updates
      }
      if (ownTransaction) {
        dbt.commit(); // commit the transaction
      }
    } catch (SQLException sqle) {
      StringBuffer message = new StringBuffer("Failed to insert/update DO: ");
      message.append(sqle.getMessage());

      // rollback, if necessary
      if (ownTransaction) {
        try {
          dbt.rollback();
        } catch (SQLException sqle2) {
          message.insert(0, "\n");
          message.insert(0, sqle2.getMessage());
          message.insert(0, "Rollback failed: ");
        }
      }
      throw new SQLException(message.toString());
    } finally {
      // release the transaction, if any
      if (ownTransaction) {
        dbt.release();
      }
    }
  }
 public String toString() {
   StringBuffer sb = new StringBuffer("X_AD_ComponentVersion[").append(getID()).append("]");
   return sb.toString();
 }
 public String toString() {
   StringBuffer sb = new StringBuffer("X_T_ReportStatement[").append(getID()).append("]");
   return sb.toString();
 }