private String getCIJobPath(ApplicationInfo appInfo) { StringBuilder builder = new StringBuilder(Utility.getProjectHome()); builder.append(appInfo.getAppDirName()); builder.append(File.separator); builder.append(FOLDER_DOT_PHRESCO); builder.append(File.separator); builder.append(CI_JOB_INFO_NAME); return builder.toString(); }
// get the caption for the loop's visual representation // the caption is an abbreviated form of the code // the caption appears in the upper-left corner of the loop public String getCaption() { String caption = ""; switch (type) { case LOOP_TYPE_REPETITIONS: if (!numWarmups.equals("0")) { caption += numWarmups + " " + Utility.wordForm(numWarmups, "warmups") + " + "; if (sync) caption += "sync + "; } caption += numReps + " " + Utility.wordForm(numReps, "reps"); return caption; case LOOP_TYPE_FOR_EACH: caption = sequenceName + " in "; for (int i = 0; i < sequences.size(); i++) { String sequence = (String) sequences.elementAt(i); if (i > 0) caption += ", "; caption += "{" + sequence + "}"; } return caption; case LOOP_TYPE_TIMED: return toCode(); default: assert false; return ""; } }
public boolean tryDamageSkill(String rem, String cut, String output) { if (cut.length() > 0) if (rem.indexOf(cut) == 0) { rem = rem.substring(cut.length(), rem.length()); rem = Utility.clearWhiteSpace(rem); } target = owner.getRoom().findEntity(owner, rem); if ((target == null) && (owner.getPlayerState() == Utility.PSTATE_FIGHTING)) target = owner.getTarget(); if (target == null) { owner.echo(output); return false; } if (!Combat.canAttack(owner, target, false, true)) return false; tn = target.getName(); Tn = target.getPName(); ty = Utility.possessive(tn); Ty = Utility.possessive(Tn); return true; }
// returns the code for the header of the loop, not code for // the entire loop that it contains public String toCode() { String code; switch (type) { case LOOP_TYPE_REPETITIONS: code = "for " + numReps + " " + Utility.wordForm(numReps, "repetitions"); if (!numWarmups.equals("0")) { code += " plus " + numWarmups + " warmup " + Utility.wordForm(numWarmups, "repetitions"); if (sync) code += " and a synchronization"; } return code; case LOOP_TYPE_FOR_EACH: code = "for each " + sequenceName + " in "; for (int i = 0; i < sequences.size(); i++) { String sequence = (String) sequences.elementAt(i); if (i > 0) code += ", "; code += "{" + sequence + "}"; } return code; case LOOP_TYPE_TIMED: code = "for " + time + " " + Utility.wordForm(time, timeUnits); return code; default: assert false; return ""; } }
private void setSvnCredential(CIJob job) throws JDOMException, IOException { S_LOGGER.debug("Entering Method CIManagerImpl.setSvnCredential"); try { String jenkinsTemplateDir = Utility.getJenkinsTemplateDir(); String credentialFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CREDENTIAL_XML; if (debugEnabled) { S_LOGGER.debug("credentialFilePath ... " + credentialFilePath); } File credentialFile = new File(credentialFilePath); SvnProcessor processor = new SvnProcessor(credentialFile); // DataInputStream in = new DataInputStream(new FileInputStream(credentialFile)); // while (in.available() != 0) { // System.out.println(in.readLine()); // } // in.close(); processor.changeNodeValue("credentials/entry//userName", job.getUserName()); processor.changeNodeValue("credentials/entry//password", job.getPassword()); processor.writeStream(new File(Utility.getJenkinsHome() + File.separator + job.getName())); // jenkins home location String jenkinsJobHome = System.getenv(JENKINS_HOME); StringBuilder builder = new StringBuilder(jenkinsJobHome); builder.append(File.separator); processor.writeStream(new File(builder.toString() + CI_CREDENTIAL_XML)); } catch (Exception e) { S_LOGGER.error( "Entered into the catch block of CIManagerImpl.setSvnCredential " + e.getLocalizedMessage()); } }
private BusinessPartnerCategoryData getEditVariables(Connection con, VariablesSecureApp vars) throws IOException, ServletException { BusinessPartnerCategoryData data = new BusinessPartnerCategoryData(); ServletException ex = null; try { data.adOrgId = vars.getRequiredGlobalVariable("inpadOrgId", windowId + "|AD_Org_ID"); data.adOrgIdr = vars.getStringParameter("inpadOrgId_R"); data.cBpGroupId = vars.getRequestGlobalVariable("inpcBpGroupId", windowId + "|C_BP_Group_ID"); data.value = vars.getStringParameter("inpvalue"); data.name = vars.getRequiredStringParameter("inpname"); data.description = vars.getStringParameter("inpdescription"); data.isactive = vars.getStringParameter("inpisactive", "N"); data.isdefault = vars.getStringParameter("inpisdefault", "N"); data.adClientId = vars.getRequiredGlobalVariable("inpadClientId", windowId + "|AD_Client_ID"); data.createdby = vars.getUser(); data.updatedby = vars.getUser(); data.adUserClient = Utility.getContext(this, vars, "#User_Client", windowId, accesslevel); data.adOrgClient = Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel); data.updatedTimeStamp = vars.getStringParameter("updatedTimestamp"); if (data.value.equals("")) data.value = Utility.getDocumentNoConnection(con, this, vars.getClient(), "C_BP_Group", true); } catch (ServletException e) { vars.setEditionData(tabId, data); throw e; } // Behavior with exception for numeric fields is to catch last one if we have multiple ones if (ex != null) { vars.setEditionData(tabId, data); throw ex; } return data; }
public void printVariable() { Utility.Dprintc("VARIABLE " + varID + " ", 0); for (int j = 0; j < domain.length; j++) { Utility.Dprintc(domain[j].toString() + " ", 0); } Utility.Dprint("", 0); }
private static DialogFeatureConfig parseDialogConfig(JSONObject dialogConfigJSON) { String dialogNameWithFeature = dialogConfigJSON.optString(DIALOG_CONFIG_NAME_KEY); if (Utility.isNullOrEmpty(dialogNameWithFeature)) { return null; } String[] components = dialogNameWithFeature.split(DIALOG_CONFIG_DIALOG_NAME_FEATURE_NAME_SEPARATOR); if (components.length != 2) { // We expect the format to be dialogName|FeatureName, where both components are // non-empty. return null; } String dialogName = components[0]; String featureName = components[1]; if (isNullOrEmpty(dialogName) || isNullOrEmpty(featureName)) { return null; } String urlString = dialogConfigJSON.optString(DIALOG_CONFIG_URL_KEY); Uri fallbackUri = null; if (!Utility.isNullOrEmpty(urlString)) { fallbackUri = Uri.parse(urlString); } JSONArray versionsJSON = dialogConfigJSON.optJSONArray(DIALOG_CONFIG_VERSIONS_KEY); int[] featureVersionSpec = parseVersionSpec(versionsJSON); return new DialogFeatureConfig(dialogName, featureName, fallbackUri, featureVersionSpec); }
/** Unit test for TupleDesc.combine() */ @Test public void combine() { TupleDesc td1, td2, td3; td1 = Utility.getTupleDesc(1, "td1"); td2 = Utility.getTupleDesc(2, "td2"); // test td1.combine(td2) td3 = TupleDesc.merge(td1, td2); assertEquals(3, td3.numFields()); assertEquals(3 * Type.INT_TYPE.getLen(), td3.getSize()); for (int i = 0; i < 3; ++i) assertEquals(Type.INT_TYPE, td3.getFieldType(i)); assertEquals(combinedStringArrays(td1, td2, td3), true); // test td2.combine(td1) td3 = TupleDesc.merge(td2, td1); assertEquals(3, td3.numFields()); assertEquals(3 * Type.INT_TYPE.getLen(), td3.getSize()); for (int i = 0; i < 3; ++i) assertEquals(Type.INT_TYPE, td3.getFieldType(i)); assertEquals(combinedStringArrays(td2, td1, td3), true); // test td2.combine(td2) td3 = TupleDesc.merge(td2, td2); assertEquals(4, td3.numFields()); assertEquals(4 * Type.INT_TYPE.getLen(), td3.getSize()); for (int i = 0; i < 4; ++i) assertEquals(Type.INT_TYPE, td3.getFieldType(i)); assertEquals(combinedStringArrays(td2, td2, td3), true); }
private void refreshSessionNew(VariablesSecureApp vars) throws IOException, ServletException { BusinessPartnerCategoryData[] data = BusinessPartnerCategoryData.selectEdit( this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage(), vars.getStringParameter("inpcBpGroupId", ""), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel)); if (data == null || data.length == 0) return; refreshSessionEdit(vars, data); }
private void writeDoCommand(PrintWriter pw, String indent) { String str = indent + "fCommandStatus = fUMart.do" + fCmdDef.getCmdName() + "("; str += Utility.makeFieldString((String) fCmdDef.getReturnData().get("NAME")); str += ", userID"; Iterator itr = fCmdDef.getArgList().iterator(); while (itr.hasNext()) { HashMap argInfo = (HashMap) itr.next(); String argName = Utility.makeFieldString((String) argInfo.get("NAME")); str += ", " + argName; } str += ");"; pw.println(str); }
public void init(Entity Owner, int Level) { owner = Owner; level = Level; if (Owner != null) { mn = owner.getName(); Mn = owner.getPName(); my = Utility.possessive(mn); My = Utility.possessive(Mn); } }
public static Intent createProxyAuthIntent( Context context, String applicationId, List<String> permissions, String e2e, boolean isRerequest, SessionDefaultAudience defaultAudience) { for (NativeAppInfo appInfo : facebookAppInfoList) { Intent intent = new Intent() .setClassName(appInfo.getPackage(), FACEBOOK_PROXY_AUTH_ACTIVITY) .putExtra(FACEBOOK_PROXY_AUTH_APP_ID_KEY, applicationId); if (!Utility.isNullOrEmpty(permissions)) { intent.putExtra(FACEBOOK_PROXY_AUTH_PERMISSIONS_KEY, TextUtils.join(",", permissions)); } if (!Utility.isNullOrEmpty(e2e)) { intent.putExtra(FACEBOOK_PROXY_AUTH_E2E_KEY, e2e); } intent.putExtra( ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN); intent.putExtra( ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE); intent.putExtra( ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, defaultAudience.getNativeProtocolAudience()); if (!Settings.getPlatformCompatibilityEnabled()) { // Override the API Version for Auth intent.putExtra( ServerProtocol.DIALOG_PARAM_LEGACY_OVERRIDE, ServerProtocol.GRAPH_API_VERSION); // Only set the rerequest auth type for non legacy requests if (isRerequest) { intent.putExtra( ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE); } } intent = validateActivityIntent(context, intent, appInfo); if (intent != null) { return intent; } } return null; }
private void writeSendingHashMap(PrintWriter pw, String indent, HashMap item, String hashName) { String coreClassName = "UC" + fCmdDef.getCmdName() + "Core"; String type = (String) item.get("TYPE"); ArrayList contents = (ArrayList) item.get("CONTENTS"); Iterator itr = contents.iterator(); while (itr.hasNext()) { HashMap item2 = (HashMap) itr.next(); String type2 = (String) item2.get("TYPE"); String name2 = (String) item2.get("NAME"); String key2 = Utility.makeKeyString(type2, name2); String comment2 = (String) item2.get("COMMENT"); String localVariableName = Utility.makeLocalVariable(name2); if (type2.equals("HashMap")) { pw.print( indent + "HashMap " + localVariableName + " = (HashMap)" + hashName + ".get(" + coreClassName + "." + key2 + ");"); pw.println(" // " + comment2); writeSendingHashMap(pw, indent, item2, localVariableName); } else if (type2.equals("ArrayList")) { pw.print( indent + "ArrayList " + localVariableName + " = (ArrayList)" + hashName + ".get(" + coreClassName + "." + key2 + ");"); pw.println(" // " + comment2); writeSendingArrayList(pw, indent, item2, localVariableName); } else { String str = indent + "fAgent.sendMessage(" + hashName + ".get("; str += "UC" + fCmdDef.getCmdName() + "Core." + key2 + ").toString());"; pw.print(str); pw.println(" // " + comment2); } } }
public static DialogFeatureConfig getDialogFeatureConfig( String applicationId, String actionName, String featureName) { if (Utility.isNullOrEmpty(actionName) || Utility.isNullOrEmpty(featureName)) { return null; } FetchedAppSettings settings = fetchedAppSettings.get(applicationId); if (settings != null) { Map<String, DialogFeatureConfig> featureMap = settings.getDialogConfigurations().get(actionName); if (featureMap != null) { return featureMap.get(featureName); } } return null; }
public boolean validateSignature(Context context, String packageName) { String brand = Build.BRAND; int applicationFlags = context.getApplicationInfo().flags; if (brand.startsWith("generic") && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { // We are debugging on an emulator, don't validate package signature. return true; } PackageInfo packageInfo = null; try { packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return false; } for (Signature signature : packageInfo.signatures) { String hashedSignature = Utility.sha1hash(signature.toByteArray()); if (validAppSignatureHashes.contains(hashedSignature)) { return true; } } return false; }
/* Get value with given name */ public Value getValue(String val) { for (int i = 0; i < domain.length; i++) if (domain[i].toString().equals(val)) return domain[i]; Utility.Dprint("Variable.getValue(): Unknown Value: " + val, Utility.TRACE_FUNCTION_LEVEL); return null; }
public static Skill createSkill(String sName, Entity ENT, int lev) { Ability A = null; Class C = null; sName = Utility.getProperClassName(sName); try { C = Class.forName(sName); A = (Ability) C.newInstance(); } catch (Exception e) { return null; } catch (Throwable t) { return null; } try { Skill Sk = (Skill) A; Sk.init(ENT, lev); return Sk; } catch (Exception e) { return null; } catch (Throwable t) { return null; } }
/** * Set up the default screen control for this field. * * @param itsLocation Location of this component on screen (ie., GridBagConstraint). * @param targetScreen Where to place this component (ie., Parent screen or GridBagLayout). * @param converter The converter to set the screenfield to. * @param iDisplayFieldDesc Display the label? (optional). * @param properties Extra properties * @return Return the component or ScreenField that is created for this field. */ public ScreenComponent setupDefaultView( ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, Map<String, Object> properties) { if (targetScreen != null) { Record recCurrencys = (Record) Utility.getRecordOwner(targetScreen).getRecord(Currencys.CURRENCYS_FILE); if (recCurrencys != null) { BaseField fldCurrencyCode = recCurrencys.getField(Currencys.CURRENCY_CODE); Converter conv = new FieldDescConverter( fldCurrencyCode, (Converter) converter); // Use the description for this field ScreenComponent sfCurrency = createScreenComponent( ScreenModel.EDIT_TEXT, itsLocation, targetScreen, conv, iDisplayFieldDesc, properties); sfCurrency.setEnabled(false); itsLocation = targetScreen.getNextLocation( ScreenConstants.RIGHT_OF_LAST, ScreenConstants.DONT_SET_ANCHOR); iDisplayFieldDesc = ScreenConstants.DONT_DISPLAY_DESC; // Display it only once } } return super.setupDefaultView( itsLocation, targetScreen, converter, iDisplayFieldDesc, properties); }
@Test public void new_getFieldTypeTest() { int length = 100; String name = "td"; TupleDesc td = Utility.getTupleDesc(length, name); // Lower than index bound. try { td.getFieldType(length + 1); fail("expected exception"); } catch (NoSuchElementException e) { } // Higher than index bound. try { td.getFieldType(-1); fail("expected exception"); } catch (NoSuchElementException e) { } // Check each name. for (int i = 0; i < length; i++) { assertEquals(Type.INT_TYPE, td.getFieldType(i)); } }
private String getSearchSqlByFilterName(String filterName, String filterVal, int filterType) { String nameFilter = ""; if (Utility.isSet(filterVal)) { switch (filterType) { case QueryRequest.BEGINS: nameFilter = " and UPPER(" + filterName + ") LIKE UPPER('" + filterVal.replaceAll("'", "''") + "%') \n"; break; case QueryRequest.CONTAINS: nameFilter = " and UPPER(" + filterName + ") LIKE UPPER('%" + filterVal.replaceAll("'", "''") + "%') \n"; break; } } return nameFilter; }
protected String getField( Segment pSegment, int pFieldNum, boolean pMandatoryFl, String pErrorMessage) { DataElement de = null; String val = null; String err = null; try { de = pSegment.getDataElement(pFieldNum); } catch (Exception exc) { if (pMandatoryFl) { err = pErrorMessage + " (1)"; } } if (err == null && de == null && pMandatoryFl) { err = pErrorMessage + " (2)"; } if (err == null && de != null) { try { val = de.get(); } catch (Exception exc) { } if (!Utility.isSet(val) && pMandatoryFl) { err = pErrorMessage + " (3)"; } } if (err != null) { errorMsgs.add(err); } return val; }
// generate the code corresponding to the compute aggregates public String toCodeComputeAggregates() { if (computeAggregatesGroup == null) return null; else return computeAggregatesGroup.toCodeSource() + " " + Utility.wordForm(computeAggregatesGroup.toCodeSource(), "computes") + " aggregates"; }
public static File createTmpFile() { try { return File.createTempFile("Utility_temp_file-" + String.valueOf(Utility.tic()), ".tmp"); } catch (IOException ex) { mylogger.log(Level.SEVERE, "Error: Can not create temp file ", ex); return null; } }
/** Unit test for TupleDesc.numFields() */ @Test public void numFields() { int[] lengths = new int[] {1, 2, 1000}; for (int len : lengths) { TupleDesc td = Utility.getTupleDesc(len); assertEquals(len, td.numFields()); } }
/** Unit test for TupleDesc.getSize() */ @Test public void getSize() { int[] lengths = new int[] {1, 2, 1000}; for (int len : lengths) { TupleDesc td = Utility.getTupleDesc(len); assertEquals(len * Type.INT_TYPE.getLen(), td.getSize()); } }
private String getDisplayLogicContext(VariablesSecureApp vars, boolean isNew) throws IOException, ServletException { log4j.debug("Output: Display logic context fields"); String result = "var strShowAudit=\"" + (isNew ? "N" : Utility.getContext(this, vars, "ShowAudit", windowId)) + "\";\n"; return result; }
/** Unit test for TupleDesc.getType() */ @Test public void getType() { int[] lengths = new int[] {1, 2, 1000}; for (int len : lengths) { TupleDesc td = Utility.getTupleDesc(len); for (int i = 0; i < len; ++i) assertEquals(Type.INT_TYPE, td.getFieldType(i)); } }
int getStatus(Exception e) { if (e instanceof JavaScriptException) { JavaScriptException je = (JavaScriptException) e; Object value = ((ScriptableObject) je.getValue()).get("message", null); if (value != null) { String status = Utility.find(value.toString(), "^\\d\\d\\d\\b"); if (status != null) return Integer.parseInt(status); } } return 500; }
/** Test one prarmeter constructor, it should set the filed name to null. */ @Test public void new_oneParamsConTest() { int[] lengths = new int[] {1, 2, 1000}; for (int len : lengths) { TupleDesc td = Utility.getTupleDesc(len); for (int i = 0; i < len; i++) { assertEquals("", td.getFieldName(i)); } } }