本文整理汇总了Java中org.simpleframework.xml.core.Validate类的典型用法代码示例。如果您正苦于以下问题:Java Validate类的具体用法?Java Validate怎么用?Java Validate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Validate类属于org.simpleframework.xml.core包,在下文中一共展示了Validate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the <code>KeyTransport</code> element included in this P-Mode.
* <p>When included the element must have at least one child. Also when the <i>RSA-OAEP</i> algorithm is specified
* an MGF algorithm must be specified.
*
* @throws PersistenceException If there is not at least one child element or when no MGF algorithm is specified in
* case <i>RSA-OAEP</i> is specified
*/
@Validate
public void validate() throws PersistenceException {
// Check at least one child element is included
if (Utils.getValue(algorithm, null) == null
&& Utils.getValue(MGFAlgorithm, null) == null
&& Utils.getValue(digestAlgorithm, null) == null
&& Utils.getValue(keyReferenceMethod.referenceMethod, null) == null)
throw new PersistenceException("KeyTransport MUST have at least one child element", null);
// Check if MGF is specified in case RSA-OAEP is kt algorithm
if (WSConstants.KEYTRANSPORT_RSAOEP_XENC11.equalsIgnoreCase(algorithm)
&& Utils.getValue(MGFAlgorithm, null) == null)
throw new PersistenceException("You MUST specify a MGF algorithm when specifying RSA-OAEP as "
+ "key transport algorithm", null);
}
示例2: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the read XML data to ensure that there are at most two UsernameToken child elements and that each
* has its own target.
*
* @throws PersistenceException When the read XML document contains more than 2 UsernameToken elements or the
* specified UsernameToken elements have the same target
*/
@Validate
public void validate() throws PersistenceException {
if (usernameTokens == null)
return;
if (usernameTokens.size() > 2)
throw new PersistenceException("There may not be more than 2 UsernameToken elements", null);
else if (usernameTokens.size() == 2) {
// Compare the target attribute value of both elements
final int c = Utils.compareStrings(usernameTokens.get(0).target, usernameTokens.get(1).target);
if (c == -1 || c == 0)
// The targets are equal
throw new PersistenceException("You must specify separate targets for the UsernameToken elements!",
null);
}
}
示例3: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Initialization method used by the Simple XML framework.
*/
@SuppressWarnings("unused")
@Validate
private void validate() {
/* Validate color. */
if (color != null) {
String[] rgb = this.color.split(",");
this.colorObject = new Color(
Integer.parseInt(rgb[0]),
Integer.parseInt(rgb[1]),
Integer.parseInt(rgb[2]));
}
/* Validate last part of name. */
validateName();
/* Create hash code. */
hashCodeValue = bitIdentifier.hashCode() ^ name.hashCode() ^ family.hashCode();
}
示例4: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validation method for the read XML information.
*
* @see org.simpleframework.xml.load.Validate
*/
@Validate
public void validate() {
/* Validate color. */
String[] rgb = this.color.split(",");
this.colorObject = new Color(
Integer.parseInt(rgb[0]),
Integer.parseInt(rgb[1]),
Integer.parseInt(rgb[2]));
/* Validate states. */
if (states != null) {
stateStates = new HashMap<String, String[]>();
Iterator<String> iterStr = states.keySet().iterator();
while (iterStr.hasNext()) {
String nextStateType = iterStr.next();
String[] stateNames = states.get(nextStateType).split(",");
Arrays.sort(stateNames);
stateStates.put(nextStateType, stateNames);
}
}
}
示例5: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate() throws ParseException {
this.company = ValidationUtils
.validateNotHavingUnderscore(ValidationUtils.validateCaseSensitiveNameAttribute(
ATTRIBUTE_PARENT_NAME, "company", company),
"The company parameter can't contain underscores. It is connected with the way the Version API reads companies. Underscores have been stripped.");
this.name = ValidationUtils
.validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "name", name);
this.project = ValidationUtils
.validateCaseSensitiveNameAttribute(ATTRIBUTE_PARENT_NAME, "project",
project);
}
示例6: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate(Map session) throws IOException {
File file = new File(root);
if(!file.exists()) {
throw new FileNotFoundException("Root path '" +file+ "' does not exist");
}
session.put(identifier, file.getAbsolutePath());
}
示例7: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate() throws Exception {
if(getSeparatedKeys().length==0)
throw new Exception("Action must have at least one key: "+keys);
if(getNextScene()!=null && getNextDialog()!=null)
throw new Exception("An action cannot have both a next dialog and next scene...");
}
示例8: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate() throws Exception {
if((text==null || text.trim().equals("")) && file==null)
throw new Exception("Audio must have either some text or a link to a file");
if((text!=null && (!text.trim().equals(""))) && file!=null)
throw new Exception("Audio cannot have both text and a link to a file");
}
示例9: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate() throws Exception {
if( ! (change.equals(INCREMENT) || change.equals(DECREMENT) || change.equals(SET_TRUE) || change.equals(SET_FALSE) || change.equals(SET_ZERO) || change.equals(SET_VALUE)) )
throw new Exception("Unknown state change: "+change);
if(change.equals(SET_VALUE) && getValue()==null)
throw new Exception("State-change 'set-value' must have a 'value' attribute");
}
示例10: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
@Validate
public void validate() throws Exception {
for(Voice v : getVoices())
if(!voiceMap.containsKey(v.getId()))
voiceMap.put(v.getId(), v);
else
throw new Exception("Duplicate voice: "+v.getId());
if(!voiceMap.containsKey(defaultVoiceId))
throw new Exception("Default voice id does not exist: "+defaultVoiceId);
}
示例11: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the read configuration. At the moment this validation only checks that each parameter is named.
*
* @throws PersistenceException When a parameter included in the XML document has no name.
*/
@Validate
public void validate() throws PersistenceException {
if (!Utils.isNullOrEmpty(parameters)) {
for (final String name : parameters.keySet())
if (Utils.isNullOrEmpty(name))
throw new PersistenceException("Each parameter in the configuration must be named!");
}
}
示例12: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the data read from the XML document by checking that when <code>MaxRetries</code> is supplied
* <code>RetryInterval</code> contains positive non zero value;</li></ol>
*
* @throws Exception When the read XML is not valid
*/
@Validate
public void validate() throws Exception {
if (maxRetries > -1)
if (retryIntervalDuration <= 0)
throw new ValueRequiredException("ReceptionAwareness/RetryInterval must have positive non zero value");
}
示例13: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the read XML data to ensure that there is at most one UsernameToken child element. This only element
* should have no <code>target</code> attribute specified or with value <i>"ebms"</i> because the sub-channel
* authentication and authorization can only use the security header targeted to this role.
*
* @throws PersistenceException When the read XML document contains more than 1 UsernameToken element
*/
@Override
@Validate
public void validate() throws PersistenceException {
if (usernameTokens == null)
return;
else if (usernameTokens.size() > 1)
throw new PersistenceException("There shall be only one UsernameToken element for PullRequestFlow", null);
}
示例14: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Validates the data read from the XML document. The validation for now only checks whether an URL is specified
* when the response pattern is set to CALLBACK
*
* @throws PersistenceException When no URL is provided when the reply pattern is set to CALLBACK
*/
@Validate
public void validate() throws PersistenceException {
if (getPattern() == ReplyPattern.CALLBACK && (to == null || to.isEmpty()))
throw new PersistenceException("You must specify the URL where to sent errors when setting"
+ " reply pattern to CALLBACK", null);
}
示例15: validate
import org.simpleframework.xml.core.Validate; //导入依赖的package包/类
/**
* Performs additional checks to ensure that the read XML document is valid according to the XSD.
* <p>Because a general definition is used for reading both the default and specific pullers there is no check
* on the number of P-Modes referenced by the pullers when the XML is deserialized. Therefor this method performs
* checks:<ol>
* <li>There are no referenced P-Modes for the default puller</li>
* <li>There is at least one reference P-Mode for each specific puller</li>
* </ol>
*
* @throws PersistenceException When the read XML fails one of the checks
*/
@Validate
private void validate() throws PersistenceException {
// Default puller should have no PModes associated with it
if(defaultPuller.pmodes != null && !defaultPuller.pmodes.isEmpty())
throw new PersistenceException("The default puller should not specify specific PModes!");
// A specific puller must specifiy at least one PMode
if(pullers != null) {
for(final PullerConfig p : pullers)
if(p.pmodes == null || p.pmodes.isEmpty())
throw new PersistenceException("Specific puller must reference at least one PMode!");
}
}