當前位置: 首頁>>代碼示例>>Java>>正文


Java RegexConstraint類代碼示例

本文整理匯總了Java中org.alfresco.repo.dictionary.constraint.RegexConstraint的典型用法代碼示例。如果您正苦於以下問題:Java RegexConstraint類的具體用法?Java RegexConstraint怎麽用?Java RegexConstraint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RegexConstraint類屬於org.alfresco.repo.dictionary.constraint包,在下文中一共展示了RegexConstraint類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testConstraintsOverrideInheritance

import org.alfresco.repo.dictionary.constraint.RegexConstraint; //導入依賴的package包/類
public void testConstraintsOverrideInheritance()
{
    QName baseQName = QName.createQName(TEST_URL, "base");
    QName fileQName = QName.createQName(TEST_URL, "file");
    QName folderQName = QName.createQName(TEST_URL, "folder");
    QName prop1QName = QName.createQName(TEST_URL, "prop1");

    // get the base property
    PropertyDefinition prop1Def = service.getProperty(baseQName, prop1QName);
    assertNotNull(prop1Def);
    List<ConstraintDefinition> prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);

    // check the inherited property on folder (must be same as above)
    prop1Def = service.getProperty(folderQName, prop1QName);
    assertNotNull(prop1Def);
    prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);

    // check the overridden property on file (must be reverse of above)
    prop1Def = service.getProperty(fileQName, prop1QName);
    assertNotNull(prop1Def);
    prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:35,代碼來源:RepoDictionaryDAOTest.java

示例2: testConstraintsOverrideInheritance

import org.alfresco.repo.dictionary.constraint.RegexConstraint; //導入依賴的package包/類
@Test
public void testConstraintsOverrideInheritance()
{
    QName baseQName = QName.createQName(TEST_URL, "base");
    QName fileQName = QName.createQName(TEST_URL, "file");
    QName folderQName = QName.createQName(TEST_URL, "folder");
    QName prop1QName = QName.createQName(TEST_URL, "prop1");

    // get the base property
    PropertyDefinition prop1Def = service.getProperty(baseQName, prop1QName);
    assertNotNull(prop1Def);
    List<ConstraintDefinition> prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);

    // check the inherited property on folder (must be same as above)
    prop1Def = service.getProperty(folderQName, prop1QName);
    assertNotNull(prop1Def);
    prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);

    // check the overridden property on file (must be reverse of above)
    prop1Def = service.getProperty(fileQName, prop1QName);
    assertNotNull(prop1Def);
    prop1Constraints = prop1Def.getConstraints();
    assertEquals("Incorrect number of constraints", 3, prop1Constraints.size());
    assertTrue("Constraint instance incorrect", prop1Constraints.get(0).getConstraint() instanceof StringLengthConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(1).getConstraint() instanceof RegexConstraint);
    assertTrue("Constraint instance incorrect", prop1Constraints.get(2).getConstraint() instanceof RegisteredConstraint);
}
 
開發者ID:Alfresco,項目名稱:alfresco-data-model,代碼行數:36,代碼來源:DictionaryDAOTest.java

示例3: setupConstraints

import org.alfresco.repo.dictionary.constraint.RegexConstraint; //導入依賴的package包/類
/**
 * Sets up client validation rules for any constraints the property has.
 * 
 * @param context FacesContext
 * propertySheet The property sheet being generated
 * @param property The property being generated
 * @param propertyDef The data dictionary definition of the property
 * @param component The component representing the property
 */
protected void setupConstraints(FacesContext context, 
      UIPropertySheet propertySheet, PropertySheetItem property, 
      PropertyDefinition propertyDef, UIComponent component)
{
   // only setup constraints if the property sheet is in edit mode,
   // validation is enabled
   if (propertySheet.inEditMode() && propertySheet.isValidationEnabled() &&
       propertyDef != null)
   {
      List<ConstraintDefinition> constraints = propertyDef.getConstraints();
      for (ConstraintDefinition constraintDef : constraints)
      {
         Constraint constraint = constraintDef.getConstraint();
            
         if (constraint instanceof RegexConstraint)
         {
            setupRegexConstraint(context, propertySheet, property, component,
                  (RegexConstraint)constraint, false);
         }
         else if (constraint instanceof StringLengthConstraint)
         {
            setupStringLengthConstraint(context, propertySheet, property, component,
                  (StringLengthConstraint)constraint, false);
         }
         else if (constraint instanceof NumericRangeConstraint)
         {
            setupNumericRangeConstraint(context, propertySheet, property, component,
                  (NumericRangeConstraint)constraint, false);
         }
         else if (constraint instanceof ListOfValuesConstraint)
         {
            // NOTE: This is dealt with at the component creation stage
            //       as a different component is usually required.
         }
      }
   }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:47,代碼來源:BaseComponentGenerator.java

示例4: newInstance

import org.alfresco.repo.dictionary.constraint.RegexConstraint; //導入依賴的package包/類
@Override
protected Constraint newInstance()
{
    return new RegexConstraint();
}
 
開發者ID:Alfresco,項目名稱:alfresco-data-model,代碼行數:6,代碼來源:M2ConstraintDefinition.java

示例5: setupRegexConstraint

import org.alfresco.repo.dictionary.constraint.RegexConstraint; //導入依賴的package包/類
/**
 * Sets up a default validation rule for the regular expression constraint
 * 
 * @param context FacesContext
 * @param propertySheet The property sheet to add the validation rule to
 * @param property The property being generated
 * @param component The component representing the property
 * @param constraint The constraint to setup
 * @param realTimeChecking true to make the client validate as the user types
 */
protected void setupRegexConstraint(FacesContext context, 
      UIPropertySheet propertySheet, PropertySheetItem property, 
      UIComponent component, RegexConstraint constraint, 
      boolean realTimeChecking)
{
   String expression = constraint.getExpression();
   boolean requiresMatch = constraint.getRequiresMatch();
   
   List<String> params = new ArrayList<String>(3);
   
   // add the value parameter
   String value = "document.getElementById('" +
         component.getClientId(context) +
         (component instanceof UIMultiValueEditor ? "_current_value" : "") +
         "')";
   params.add(value);
   
   // add the regular expression parameter
   try
   {
      // encode the expression so it can be unescaped by JavaScript
      addStringConstraintParam(params, URLEncoder.encode(expression, "UTF-8"));
   }
   catch (UnsupportedEncodingException e)
   {
      // just add the expression as is
      addStringConstraintParam(params, expression);
   }
   
   // add the requiresMatch parameter
   params.add(Boolean.toString(requiresMatch));
   
   // add the validation failed messages
   String matchMsg = Application.getMessage(context, "validation_regex");
   addStringConstraintParam(params, 
         MessageFormat.format(matchMsg, new Object[] {property.getResolvedDisplayLabel()}));

   String noMatchMsg = Application.getMessage(context, "validation_regex_not_match");
   addStringConstraintParam(params,
         MessageFormat.format(noMatchMsg, new Object[] {property.getResolvedDisplayLabel()}));
   
   // add the validation case to the property sheet
   propertySheet.addClientValidation(new ClientValidation((component instanceof UIMultiValueEditor ? "validateMultivalueRegex" : "validateRegex"),
      params, realTimeChecking));
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:56,代碼來源:BaseComponentGenerator.java


注:本文中的org.alfresco.repo.dictionary.constraint.RegexConstraint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。