public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("mobignore")) { if (!plugin.ah.isAuthorized(cs, "rcmds.mobignore")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { if (!(cs instanceof Player)) { cs.sendMessage(cmd.getDescription()); return false; } Player p = (Player) cs; PConfManager pcm = PConfManager.getPConfManager(p); Boolean isHidden = pcm.getBoolean("mobignored"); if (isHidden == null) isHidden = false; pcm.set("mobignored", !isHidden); String status = BooleanUtils.toStringOnOff(isHidden); cs.sendMessage( MessageColor.POSITIVE + "Toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + "."); return true; } Player t = plugin.getServer().getPlayer(args[0]); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist."); return true; } PConfManager pcm = PConfManager.getPConfManager(t); Boolean isHidden = pcm.getBoolean("mobignored"); if (isHidden == null) isHidden = false; pcm.set("mobignored", !isHidden); String status = BooleanUtils.toStringOnOff(isHidden); cs.sendMessage( MessageColor.POSITIVE + "Toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + " for " + MessageColor.NEUTRAL + t.getName() + MessageColor.POSITIVE + "."); t.sendMessage( MessageColor.NEUTRAL + cs.getName() + MessageColor.POSITIVE + " toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + " for you."); return true; } return false; }
@RequestMapping(value = "/levelsByForm", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<SignatureLevel> getAllowedLevelsByForm( @RequestParam("form") SignatureForm signatureForm, @RequestParam("isSign") Boolean isSign) { List<SignatureLevel> levels = new ArrayList<SignatureLevel>(); if (signatureForm != null) { switch (signatureForm) { case CAdES: if (BooleanUtils.isTrue(isSign)) { levels.add(SignatureLevel.CAdES_BASELINE_B); } levels.add(SignatureLevel.CAdES_BASELINE_T); levels.add(SignatureLevel.CAdES_BASELINE_LT); levels.add(SignatureLevel.CAdES_BASELINE_LTA); break; case PAdES: if (BooleanUtils.isTrue(isSign)) { levels.add(SignatureLevel.PAdES_BASELINE_B); } levels.add(SignatureLevel.PAdES_BASELINE_T); levels.add(SignatureLevel.PAdES_BASELINE_LT); levels.add(SignatureLevel.PAdES_BASELINE_LTA); break; case XAdES: if (BooleanUtils.isTrue(isSign)) { levels.add(SignatureLevel.XAdES_BASELINE_B); } levels.add(SignatureLevel.XAdES_BASELINE_T); levels.add(SignatureLevel.XAdES_BASELINE_LT); levels.add(SignatureLevel.XAdES_BASELINE_LTA); break; case ASiC_S: if (BooleanUtils.isTrue(isSign)) { levels.add(SignatureLevel.ASiC_S_BASELINE_B); } levels.add(SignatureLevel.ASiC_S_BASELINE_T); levels.add(SignatureLevel.ASiC_S_BASELINE_LT); levels.add(SignatureLevel.ASiC_S_BASELINE_LTA); break; case ASiC_E: if (BooleanUtils.isTrue(isSign)) { levels.add(SignatureLevel.ASiC_E_BASELINE_B); } levels.add(SignatureLevel.ASiC_E_BASELINE_T); levels.add(SignatureLevel.ASiC_E_BASELINE_LT); levels.add(SignatureLevel.ASiC_E_BASELINE_LTA); break; default: break; } } return levels; }
/** 将0=1/1=1/true的恒等式进行优化 */ private static IFilter shortestFilter(IFilter root) throws EmptyResultFilterException { IFilter filter = FilterUtils.toDNFAndFlat(root); List<List<IFilter>> DNFfilter = FilterUtils.toDNFNodesArray(filter); List<List<IFilter>> newDNFfilter = new ArrayList<List<IFilter>>(); for (List<IFilter> andDNFfilter : DNFfilter) { boolean isShortest = false; List<IFilter> newAndDNFfilter = new ArrayList<IFilter>(); for (IFilter one : andDNFfilter) { if (one.getOperation() == OPERATION.CONSTANT) { boolean flag = false; if (((IBooleanFilter) one).getColumn() instanceof ISelectable) { // 可能是个not函数 newAndDNFfilter.add(one); // 不能丢弃 } else { String value = ((IBooleanFilter) one).getColumn().toString(); if (StringUtils.isNumeric(value)) { flag = BooleanUtils.toBoolean(Integer.valueOf(value)); } else { flag = BooleanUtils.toBoolean(((IBooleanFilter) one).getColumn().toString()); } if (!flag) { isShortest = true; break; } } } else { newAndDNFfilter.add(one); } } if (!isShortest) { if (newAndDNFfilter.isEmpty()) { // 代表出现为true or xxx,直接返回true IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter(); f.setOperation(OPERATION.CONSTANT); f.setColumn("1"); f.setColumnName(ObjectUtils.toString("1")); return f; } else { // 针对非false的情况 newDNFfilter.add(newAndDNFfilter); } } } if (newDNFfilter.isEmpty()) { throw new EmptyResultFilterException("空结果"); } return FilterUtils.DNFToOrLogicTree(newDNFfilter); }
public Collations( String name, String characterSetName, int id, boolean isDefault, boolean isCompiled, long sortlen) { this.name = name; this.characterSetName = characterSetName; this.id = id; this.isDefault = BooleanUtils.toInteger(isDefault); this.isCompiled = BooleanUtils.toInteger(isCompiled); this.sortlen = sortlen; }
public StdioMessageReceiver( Connector connector, Service service, InboundEndpoint endpoint, long checkFrequency) throws CreateException { super(connector, service, endpoint); this.setFrequency(checkFrequency); this.connector = (StdioConnector) connector; String streamName = endpoint.getEndpointURI().getAddress(); if (StdioConnector.STREAM_SYSTEM_IN.equalsIgnoreCase(streamName)) { inputStream = System.in; } else { inputStream = this.connector.getInputStream(); } // apply connector-specific properties if (connector instanceof PromptStdioConnector) { PromptStdioConnector ssc = (PromptStdioConnector) connector; String promptMessage = (String) endpoint.getProperties().get("promptMessage"); if (promptMessage != null) { ssc.setPromptMessage(promptMessage); } } this.sendStream = BooleanUtils.toBoolean((String) endpoint.getProperties().get("sendStream")); }
@Override public void writeAttribute(String localName, String value) throws XMLStreamException { try { if (!objectQueue.isEmpty()) { if (StringUtils.equals(CmsConstants.EXPORT_AS_AN_ARRAY_INSTRUCTION, localName)) { objectQueue.peek().exportAsAnArray = BooleanUtils.isTrue(BooleanUtils.toBoolean(value)); } else { objectQueue.peek().addAttribute(localName, value); } } } catch (Exception e) { throw new XMLStreamException(e); } }
private void ensurePasswordOrPamAuth(Integer usePamAuth, String password) throws FaultException { if (!BooleanUtils.toBoolean(usePamAuth, new Integer(1), new Integer(0)) && StringUtils.isEmpty(password)) { throw new FaultException( -501, "passwordRequiredOrUsePam", "Password is required if not using PAM authentication"); } }
@CheckForNull private static Double getDoubleValue(MeasureDto measure, Metric metric) { Double value = measure.getValue(); if (BooleanUtils.isTrue(metric.isOptimizedBestValue()) && value == null) { value = metric.getBestValue(); } return value; }
private void validateHighAvailability(String formName) { if (HighAvailability.isVplexDistributed(highAvailability)) { Validation.required(formName + ".haVirtualArray", haVirtualArray); if (ProtectionSystemTypes.isRecoverPoint(remoteProtection)) { if (BooleanUtils.isNotTrue(protectSourceSite) && BooleanUtils.isNotTrue(protectHASite)) { Validation.addError( formName + ".protectSourceSite", Messages.get("vpool.protectSourceSite.error")); Validation.addError( formName + ".protectHASite", Messages.get("vpool.protectHASite.error")); } } } if (!ProtectionSystemTypes.isRecoverPointOrNone(remoteProtection)) { Validation.addError(formName + ".remoteProtection", "vpool.remoteProtection.error.vplex"); } }
@POST @Path("@addContent") @Override public Response doAddContent() throws ClientException { String name = ctx.getForm().getString("name"); boolean overwrite = BooleanUtils.toBoolean(ctx.getForm().getString("overwritePage")); return addContent(name, PageCreationLocation.TOP, overwrite, ctx.getForm()); }
private Response attachDiskToVm(Disk disk) { boolean isDiskActive = BooleanUtils.toBooleanDefaultIfNull(disk.isActive(), false); boolean isDiskReadOnly = BooleanUtils.toBooleanDefaultIfNull(disk.isReadOnly(), false); AttachDetachVmDiskParameters params = new AttachDetachVmDiskParameters( parentId, Guid.createGuidFromStringDefaultEmpty(disk.getId()), isDiskActive, isDiskReadOnly); if (disk.isSetSnapshot()) { validateParameters(disk, "snapshot.id"); params.setSnapshotId(asGuid(disk.getSnapshot().getId())); } return performAction(VdcActionType.AttachDiskToVm, params); }
/** * Will conditionally append the verbose switch if verbose flag is "true". * * @param verboseFlag String which takes null or "true". * @return Rake command builder. */ @SuppressWarnings("unchecked") public T addIfVerbose(@Nullable String verboseFlag) { if (BooleanUtils.toBoolean(verboseFlag)) { getCommandList().add(VERBOSE_ARG); } return (T) this; }
private static boolean getBoolean(Element element, String name) { if (element == null) { return false; } else { String text = element.getChildTextTrim(name); return BooleanUtils.toBoolean(text); } }
/** * Returns the value as a {@link Double} value. The returned value will be <code>0</code> or * <code>1</code> if the {@link #value} is a boolean value. If {@link #value} can not be converted * into a number, a {@link NumberFormatException} is thrown. * * @return {@link #value} as {@link Double} */ public double getValueAsDouble() { if (NumberUtils.isNumber(value)) { return NumberUtils.createDouble(value); } if (isBooleanValue(value)) { return BooleanUtils.toBoolean(value) ? 1 : 0; } throw new NumberFormatException(); }
public NiftyInstanceResponse(NiftyInstance niftyInstance) { this.instanceType = niftyInstance.getInstanceType(); this.status = niftyInstance.getStatus(); this.dnsName = niftyInstance.getDnsName(); this.privateDnsName = niftyInstance.getPrivateDnsName(); this.ipAddress = niftyInstance.getIpAddress(); this.privateIpAddress = niftyInstance.getPrivateIpAddress(); this.initialized = BooleanUtils.isTrue(niftyInstance.getInitialized()); }
public static void fromFudgeMsg( FudgeDeserializer deserializer, FudgeMsg msg, EquitySecurity object) { FinancialSecurityFudgeBuilder.fromFudgeMsg(deserializer, msg, object); object.setShortName(msg.getString(SHORT_NAME_FIELD_NAME)); object.setExchange(msg.getString(EXCHANGE_FIELD_NAME)); object.setExchangeCode(msg.getString(EXCHANGE_CODE_FIELD_NAME)); object.setCompanyName(msg.getString(COMPANY_NAME_FIELD_NAME)); object.setCurrency(msg.getValue(Currency.class, CURRENCY_FIELD_NAME)); object.setGicsCode(msg.getValue(GICSCode.class, GICS_CODE_FIELD_NAME)); object.setPreferred(BooleanUtils.isTrue(msg.getBoolean(PREFERRED_FIELD_NAME))); }
/** * Constructor called from Jelly with parameters. * * @param name name * @param description description * @param script script * @param choiceType choice type * @param referencedParameters referenced parameters * @param omitValueField used in the UI to decide whether to include a hidden empty <input * name=value>. <code>false</code> by default. */ @DataBoundConstructor public DynamicReferenceParameter( String name, String description, Script script, String choiceType, String referencedParameters, Boolean omitValueField) { super(name, description, script, referencedParameters); this.choiceType = StringUtils.defaultIfBlank(choiceType, PARAMETER_TYPE_SINGLE_SELECT); this.omitValueField = BooleanUtils.toBooleanDefaultIfNull(omitValueField, Boolean.FALSE); }
public String getMessage(String code, Object args[], String defaultMessage, Locale locale) { try { return messageSource.getMessage(code, args, defaultMessage, locale); } catch (Exception e) { LOG.error( "This message key doesn't exist: " + code + ", for this locale: " + locale.toString()); if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) { return getMessage(code, args, defaultMessage, new Locale(Constants.DEFAULT_LOCALE_CODE)); } } return null; }
public Boolean isOverriden() { Boolean result = false; TypeJavaSymbol enclosingClass = enclosingClass(); for (JavaType.ClassJavaType superType : enclosingClass.superTypes()) { Boolean overrideFromType = overridesFromSymbol(superType); if (overrideFromType == null) { result = null; } else if (BooleanUtils.isTrue(overrideFromType)) { return true; } } return result; }
/* * (non-Javadoc) * * @see * org.hoteia.qalingo.core.i18n.message.CoreMessageSource#getMessage(java * .lang.String, java.lang.Object[], java.util.Locale) */ public String getMessage(final String code, final Object args[], final Locale locale) throws NoSuchMessageException { try { return messageSource.getMessage(code, args, locale); } catch (Exception e) { logger.info( "This message key doesn't exist: " + code + ", for this locale: " + locale.toString()); if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) { return getMessage(code, args, new Locale(Constants.DEFAULT_LOCALE_CODE)); } } return null; }
/* (non-Javadoc) * @see com.hundsun.ares.studio.jres.ui.viewers.BaseEObjectColumnLabelProvider#getCopyText(java.lang.Object) */ @Override public String getCopyText(Object element) { Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN) || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT)) { return BooleanUtils.toStringTrueFalse((Boolean) p.eGet(feature)); } else { return super.getCopyText(element); } }
/** * Méthode en charge de construire la liste des items pour un thème du modèle. Il s'agit de * construire un item par catégorie et par thème/catégorie. * * @param grille La grille. * @param theme Le thème. * @return La liste des items correspondants aux catégories. */ private Collection<Item> buildItems(final Grille grille, final Theme theme) { final SortedSet<Item> items = new TreeSet<Item>(new ItemComparator()); // Gestion des thèmes qui sont aussi des catégories if (BooleanUtils.isTrue(theme.isCategorie())) { items.add(this.buildItem(grille, theme, null)); } // gestion des catégories. for (final Categorie categorie : theme.getCategories()) { items.add(this.buildItem(grille, theme, categorie)); } return items; }
@PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) public Response putJSON(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) { PortfolioDocument doc = data().getPortfolio(); if (doc.isLatest() == false) { return Response.status(Status.FORBIDDEN).entity(getHTML()).build(); } name = StringUtils.trimToNull(name); DocumentVisibility visibility = BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE; updatePortfolio(name, visibility, doc); return Response.ok().build(); }
/** * Creates a new user * * @param loggedInUser The current user * @param desiredLogin The login for the new user * @param desiredPassword The password for the new user * @param firstName The first name of the new user * @param lastName The last name of the new user * @param email The email address for the new user * @param usePamAuth Should this user authenticate via PAM? * @return Returns 1 if successful (exception otherwise) * @throws FaultException A FaultException is thrown if the loggedInUser doesn't have permissions * to create new users in thier org. * @xmlrpc.doc Create a new user. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param_desc("string", "desiredLogin", "Desired login name, will fail if already * in use.") * @xmlrpc.param #param("string", "desiredPassword") * @xmlrpc.param #param("string", "firstName") * @xmlrpc.param #param("string", "lastName") * @xmlrpc.param #param_desc("string", "email", "User's e-mail address.") * @xmlrpc.param #param_desc("int", "usePamAuth", "1 if you wish to use PAM authentication for * this user, 0 otherwise.") * @xmlrpc.returntype #return_int_success() */ public int create( User loggedInUser, String desiredLogin, String desiredPassword, String firstName, String lastName, String email, Integer usePamAuth) throws FaultException { // Logged in user must be an org admin and we must be on a sat to do this. ensureOrgAdmin(loggedInUser); ensurePasswordOrPamAuth(usePamAuth, desiredPassword); boolean pamAuth = BooleanUtils.toBoolean(usePamAuth, new Integer(1), new Integer(0)); if (pamAuth) { desiredPassword = getDefaultPasswordForPamAuth(); } CreateUserCommand command = new CreateUserCommand(); command.setUsePamAuthentication(pamAuth); command.setLogin(desiredLogin); command.setPassword(desiredPassword); command.setFirstNames(firstName); command.setLastName(lastName); command.setEmail(email); command.setOrg(loggedInUser.getOrg()); command.setCompany(loggedInUser.getCompany()); // Validate the user to be ValidatorError[] errors = command.validate(); if (errors.length > 0) { StringBuilder errorString = new StringBuilder(); LocalizationService ls = LocalizationService.getInstance(); // Build a sane error message here for (int i = 0; i < errors.length; i++) { ValidatorError err = errors[i]; errorString.append(ls.getMessage(err.getKey(), err.getValues())); if (i != errors.length - 1) { errorString.append(" :: "); } } // Throw a BadParameterException with our message string throw new BadParameterException(errorString.toString()); } command.storeNewUser(); return 1; }
/** * Will conditionally add bundle exec if bundle flag is "true". * * @param bundleFlag String which takes null or "true". * @return T command builder. */ @SuppressWarnings("unchecked") public T addIfBundleExec(@Nullable String bundleFlag) { if (BooleanUtils.toBoolean(bundleFlag)) { getCommandList() .add( getRvmRubyLocator() .buildExecutablePath( getRubyRuntime().getRubyRuntimeName(), getRubyExecutablePath(), BUNDLE_COMMAND)); getCommandList().add(BUNDLE_EXEC_ARG); } return (T) this; }
/** * Convert the specified object into a Boolean. Internally the {@code * org.apache.commons.lang.BooleanUtils} class from the <a * href="http://commons.apache.org/lang/">Commons Lang</a> project is used to perform this * conversion. This class accepts some more tokens for the boolean value of <b>true</b>, e.g. * {@code yes} and {@code on}. Please refer to the documentation of this class for more details. * * @param value the value to convert * @return the converted value * @throws ConversionException thrown if the value cannot be converted to a boolean */ public static Boolean toBoolean(Object value) throws ConversionException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Boolean b = BooleanUtils.toBooleanObject((String) value); if (b == null) { throw new ConversionException( "The value " + value + " can't be converted to a Boolean object"); } return b; } else { throw new ConversionException( "The value " + value + " can't be converted to a Boolean object"); } }
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { try { return messageSource.getMessage(resolvable, locale); } catch (Exception e) { LOG.error( "This message key doesn't exist: " + resolvable.getCodes() + ", for this locale: " + locale.toString()); if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) { return getMessage(resolvable, new Locale(Constants.DEFAULT_LOCALE_CODE)); } } return null; }
/** * @param volumeId * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm( @ModelAttribute("command") ShowExplorerVolumeCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); VolumeExplorer volumeExplorer = new VolumeExplorer(command.getSummaryId(), command.getVolNum(), command.getVolLetExt()); volumeExplorer.setImage(new Image()); volumeExplorer.getImage().setImageProgTypeNum(command.getImageProgTypeNum()); volumeExplorer .getImage() .setMissedNumbering(StringUtils.nullTrim(command.getMissedNumbering())); volumeExplorer .getImage() .setImageRectoVerso( Image.ImageRectoVerso.convertFromString( StringUtils.nullTrim(command.getImageRectoVerso()))); volumeExplorer.getImage().setImageOrder(command.getImageOrder()); volumeExplorer.getImage().setImageType(command.getImageType()); volumeExplorer.getImage().setInsertNum(StringUtils.nullTrim(command.getInsertNum())); volumeExplorer .getImage() .setInsertLet( StringUtils.isNullableString(command.getInsertNum()) ? null : command.getInsertLet()); volumeExplorer.setTotal(command.getTotal()); volumeExplorer.setTotalRubricario(command.getTotalRubricario()); volumeExplorer.setTotalCarta(command.getTotalCarta()); volumeExplorer.setTotalAppendix(command.getTotalAppendix()); volumeExplorer.setTotalOther(command.getTotalOther()); volumeExplorer.setTotalGuardia(command.getTotalGuardia()); try { volumeExplorer = getVolBaseService().getVolumeExplorer(volumeExplorer); model.put("volumeExplorer", volumeExplorer); Boolean hasInserts = getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt()); model.put("hasInsert", hasInserts); } catch (ApplicationThrowable ath) { } if (BooleanUtils.isTrue(command.getModalWindow())) { return new ModelAndView("volbase/ShowExplorerVolumeModalWindow", model); } else { return new ModelAndView("volbase/ShowExplorerVolume", model); } }
private static void validateConfiguration(final PersistedConfigurationAdapter pca) throws IOException { if (BooleanUtils.toBoolean( System.getProperty(ConfigurationFactory.class.getName() + ".skipValidation"))) { LOGGER.info("Skipped validation of: " + pca); return; } final Set<String> validationErrors = validate(pca); Validate.isTrue( validationErrors.isEmpty(), "Validation error(s):\n" + StringUtils.join(validationErrors, "\n") + "\nfound in configuration:\n" + pca); LOGGER.info("Successfully validated: " + pca); }
public void propertiesUpdated(Map<String, ?> properties) throws Exception { log.warn("Properties Reloading: " + properties); String userName = (String) properties.get("userName"); String uri = (String) properties.get("uri"); String existHome = (String) properties.get("existHome"); String password = (String) properties.get("password"); boolean useChangeSets = BooleanUtils.toBoolean((Boolean) properties.get("useChangeSets")); this.userName = userName; this.uri = uri; this.existHome = existHome; this.password = password; this.useChangeSets = useChangeSets; this.afterPropertiesSet(); }