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


Java RegExp.compile方法代碼示例

本文整理匯總了Java中com.google.gwt.regexp.shared.RegExp.compile方法的典型用法代碼示例。如果您正苦於以下問題:Java RegExp.compile方法的具體用法?Java RegExp.compile怎麽用?Java RegExp.compile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.regexp.shared.RegExp的用法示例。


在下文中一共展示了RegExp.compile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testInitWidget

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
@Test
public void testInitWidget() {
    widget.init();
    verify(widget,
           times(1)).init();
    verify(dataTypeComboBox,
           times(1)).init(widget,
                          true,
                          dataType,
                          customDataType,
                          false,
                          true,
                          VariableListItemWidgetView.CUSTOM_PROMPT,
                          VariableListItemWidgetView.ENTER_TYPE_PROMPT);
    verify(name,
           times(1)).setRegExp(regExpCaptor.capture(),
                               anyString(),
                               anyString());
    RegExp regExp = RegExp.compile(regExpCaptor.getValue());
    assertEquals(false,
                 regExp.test("a 1"));
    assertEquals(false,
                 regExp.test("[email protected]"));
    assertEquals(true,
                 regExp.test("a1"));
    verify(customDataType,
           times(1)).addKeyDownHandler(any(KeyDownHandler.class));
    verify(name,
           times(1)).addBlurHandler(any(BlurHandler.class));
}
 
開發者ID:kiegroup,項目名稱:kie-wb-common,代碼行數:31,代碼來源:VariableListItemWidgetTest.java

示例2: parseTag

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
public static String[] parseTag(final String tag) {
    String[] result = null;
    if (tag != null) {
        RegExp regExp = RegExp.compile(IMAGE_TAG_PATTERN);
        MatchResult matcher = regExp.exec(tag);
        boolean matchFound = matcher != null; 

        if (matchFound) {
            result = new String[matcher.getGroupCount()];
            // Get all groups for this match
            for (int i = 0; i < matcher.getGroupCount(); i++) {
                String groupStr = matcher.getGroup(i);
                result[i] = groupStr;
            }
        }
    }
    return result;
}
 
開發者ID:kiegroup,項目名稱:kie-docker-ci,代碼行數:19,代碼來源:SharedUtils.java

示例3: getHash

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
/**
 * Gets the true hash value. Cannot use location.hash directly due to bug
 * in Firefox where location.hash will always be decoded.
 *
 * @param iframe
 * @return
 */
public String getHash(IFrameElement iframe) {
    RegExp re = RegExp.compile("#(.*)$");
    String href = location.getHref();

    if(iframe != null) {
        href = getIFrameUrl(iframe);
    }

    MatchResult result = re.exec(href);
    return result != null && result.getGroupCount() > 1 ? result.getGroup(1) : "";
}
 
開發者ID:liraz,項目名稱:gwt-backbone,代碼行數:19,代碼來源:History.java

示例4: transformResponse

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
@Override
    protected void transformResponse(DSResponse response, DSRequest request, Object data) {
        if (RestConfig.isStatusOk(response)) {
            for (Record record : response.getData()) {
                String path = record.getAttribute(FIELD_PATH);
                RegExp pathRegExp = RegExp.compile("(.*/)?(.*)/$");
                MatchResult mr = pathRegExp.exec(path);
                String parent = mr.getGroup(1);
                String name = mr.getGroup(2);
//                System.out.println("## ITRDS.path: " + path);
//                System.out.println("## ITRDS.parent: " + parent);
//                System.out.println("## ITRDS.name: " + name);

                record.setAttribute(FIELD_NAME, name);
                record.setAttribute(FIELD_PARENT, parent);
            }
        }
        super.transformResponse(response, request, data);
    }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:20,代碼來源:ImportTreeDataSource.java

示例5: initialize

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
@Override
public void initialize(final Email emailAnnotation) {
  super.initialize(emailAnnotation);

  final Pattern.Flag[] flags = emailAnnotation.flags();
  final StringBuilder flagString = new StringBuilder();
  for (final Pattern.Flag flag : flags) {
    flagString.append(this.toString(flag));
  }

  // we only apply the regexp if there is one to apply
  if (!".*".equals(emailAnnotation.regexp()) || emailAnnotation.flags().length > 0) {
    try {
      this.pattern = RegExp.compile(emailAnnotation.regexp(), flagString.toString());
    } catch (final RuntimeException e) {
      throw LOG.getInvalidRegularExpressionException(e);
    }
  }
}
 
開發者ID:ManfredTremmel,項目名稱:gwt-bean-validators,代碼行數:20,代碼來源:EmailValidator.java

示例6: getLinkHost

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
/**
 * Returns the domain of a link, for displaying next to link.  Examples:
 *  http://ourbugsoftware/1239123 -> [ourbugsoftware/]
 *  http://testcases.example/mytest/1234 -> [testcases.example/]
 *
 * If the protocol isn't whitelisted (see PROTOCOL_WHITELIST) or the URL can't be parsed,
 * this will return null.
 *
 * @param link the full URL
 * @return the host of the URL.  Null if protocol isn't in PROTOCOL_WHITELIST or URL can't be
 * parsed.
 */
public static String getLinkHost(String link) {
  if (link != null) {
    // It doesn't seem as if java.net.URL is GWT-friendly.  Thus...  GWT regular expressions!
    RegExp regExp = RegExp.compile("(\\w+?)://([\\-\\.\\w]+?)/.*");
    // toLowerCase is okay because nothing we're interested in is case sensitive.
    MatchResult result = regExp.exec(link.toLowerCase());

    if (result != null) {
      String protocol = result.getGroup(1);
      String host = result.getGroup(2);
      if (PROTOCOL_WHITELIST.contains(protocol)) {
        return "[" + host + "/]";
      }
    }
  }
  return null;
}
 
開發者ID:rodion-goritskov,項目名稱:test-analytics-ng,代碼行數:30,代碼來源:LinkUtil.java

示例7: validateItemUrl

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
private boolean validateItemUrl(FormValidatorInfo formValidator) {
		if (urlValidator == null) {
			// [AD] Added \\[ \\] \\( \\) - brackets for the URL validation
//			urlValidator = RegExp.compile("^((ftp|http|https)://[\\[email protected]\\-\\_]+\\.[a-zA-Z]{2,}(:\\d{1,5})?(/[\\w#!:.?+=&%@!\\[\\]\\(\\)\\_\\-/]+)*){1}$");
		        
			// regex where top level domain is not required
			urlValidator = RegExp.compile("^((ftp|http|https)://[\\[email protected]\\-\\_]+(:\\d{1,5})?(/[\\w #!:.?+=&%@!\\[\\]\\(\\)\\_\\-/]+)*){1}$");
		        
		}
		Object value = getUiElementValue(formValidator);
		
		if (value != null && value instanceof String) {
			String s = (String) value;
			
			if (urlValidator.exec(s) != null) {
				return true;
			}
				
			addErrorMessage("* " + formValidator.getUiElementName() + " is not a valid URL.");
		}
		
		return false;
	}
 
開發者ID:Rise-Vision,項目名稱:rva,代碼行數:24,代碼來源:FormValidatorWidget.java

示例8: RegexValidator

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
/**
 * Construct a validator that matches any one of the set of regular
 * expressions with the specified case sensitivity.
 *
 * @param regexs The set of regular expressions this validator will
 * validate against
 * @param caseSensitive when <code>true</code> matching is <i>case
 * sensitive</i>, otherwise matching is <i>case in-sensitive</i>
 */
public RegexValidator(String[] regexs, boolean caseSensitive) {
    if (regexs == null || regexs.length == 0) {
        throw new IllegalArgumentException("Regular expressions are missing");
    }
    patterns = new RegExp[regexs.length];
    for (int i = 0; i < regexs.length; i++) {
        if (regexs[i] == null || regexs[i].length() == 0) {
            throw new IllegalArgumentException("Regular expression[" + i + "] is missing");
        }
        if (caseSensitive) {
            patterns[i] =  RegExp.compile(regexs[i]);
        } else {
            patterns[i] =  RegExp.compile(regexs[i], "i");
        }
    }
}
 
開發者ID:ManfredTremmel,項目名稱:gwt-commons-validator,代碼行數:26,代碼來源:RegexValidator.java

示例9: toRegex

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
public static RegExp toRegex(String value) {
    // a pattern matching filter - convert value to regexp
    // 1. first hide 'escaped' stars so the aren't replaced later
    value = value.replace("\\*", "~~ESCAPED_STAR~~");
    
    // 2. replace all other backslashed chars with their actual values
    value = value.replaceAll("\\\\(.)", "$1");
    
    // 3. first escape the back slashes (before we escape the other chars
    value = escapeAll(value, "\\");
    
    // 4. escape regexp special chars (other than star and backslash)
    value = escapeAll(value, "?+.[]()^${}");
    
    // 5. convert wildcards into .*
    value = value.replace("*", ".*");
    
    // 6. put back escaped starts
    value = value.replace("~~ESCAPED_STAR~~", "\\*");
    
    RegExp regex = RegExp.compile(value);
    return regex;
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:24,代碼來源:PatternMatchingFilter.java

示例10: isImageDataUri

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
private static boolean isImageDataUri(String schemeSpecificPart)
{
	RegExp regExp = RegExp.compile("([^,]*?)(;base64)?,(.*)", "mi");
	MatchResult result = regExp.exec(schemeSpecificPart);
	
	if (result != null )
	{
		String mimeType = result.getGroup(DATA_URI.TYPE.ordinal());
		for( int i = 0; i < ALLOWED_IMAGE_TYPES.length; i++ )
		{
			if( ALLOWED_IMAGE_TYPES[i].equals(mimeType) )
			{
				return true;
			}
		}
	}
	
	return false;
}
 
開發者ID:dougkoellmer,項目名稱:swarm,代碼行數:20,代碼來源:U_UriPolicy.java

示例11: calculateEnabled

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
public boolean calculateEnabled(String value, String flag)
{
   boolean result = false;
   if (value != null && RegExp.compile(FLAGS_PATTERN).test(value))
   {
      MatchResult match;
      RegExp flagsPattern = RegExp.compile(FLAGS_PATTERN);

      if ((match = flagsPattern.exec(value)) != null)
      {
         String on = match.getGroup(1);
         String off = match.getGroup(3);

         if (off != null && off.contains(flag))
            result = false;
         else if (on != null && on.contains(flag))
            result = true;
         else
            result = false;
      }
   }
   else
      result = false;

   return result;
}
 
開發者ID:ocpsoft,項目名稱:regex-tester,代碼行數:27,代碼來源:FlagToggle.java

示例12: isValidUrl

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
private static boolean isValidUrl(String url, boolean topLevelDomainRequired) {
  if (urlValidator == null || urlPlusTldValidator == null) {
    urlValidator = RegExp
        .compile("^((ftp|http|https)://[\\[email protected]\\-\\_]+(:\\d{1,5})?(/[\\w#!:.?+=&%@!~\\_\\-/]+)*){1}$");
    urlPlusTldValidator = RegExp
        .compile("^((ftp|http|https)://[\\[email protected]\\-\\_]+\\.[a-zA-Z]{2,}(:\\d{1,5})?(/[\\w#!:.?+=&%@!~\\_\\-/]+)*){1}$");
  }
  return (topLevelDomainRequired ? urlPlusTldValidator : urlValidator)
      .exec(url) != null;
}
 
開發者ID:KnowledgeCaptureAndDiscovery,項目名稱:ontosoft,代碼行數:11,代碼來源:Validators.java

示例13: getFileTypeByNamePattern

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
@Override
public FileType getFileTypeByNamePattern(String name) {
  if (!Strings.isNullOrEmpty(name)) {
    for (FileType type : fileTypes) {
      if (type.getNamePattern() != null) {
        RegExp regExp = RegExp.compile(type.getNamePattern());
        if (regExp.test(name)) {
          return type;
        }
      }
    }
  }

  return unknownFileType;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:16,代碼來源:FileTypeRegistryImpl.java

示例14: selectWordCounter

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
public static WordCounter selectWordCounter(String text) {
    final RegExp rFull = RegExp.compile("[\\u3040-\\uA4CF]", "g");
    final RegExp rLetter = RegExp.compile("[\\uAC00-\\uD7AF]", "g");

    if (rFull.test(text)) {
        return new FullWordCounter();
    } else if (rLetter.test(text)) {
        return new LetterWordCounter();
    } else {
        return new FastWordCounter();
    }
}
 
開發者ID:chromium,項目名稱:dom-distiller,代碼行數:13,代碼來源:StringUtil.java

示例15: beautifyName

import com.google.gwt.regexp.shared.RegExp; //導入方法依賴的package包/類
private String beautifyName(String mbeanName) {
    // sigar:Name=lo,Type=NetInterface
    String patternStr = "sigar:Name=(.*),Type=CpuCore";
    RegExp pattern = RegExp.compile(patternStr);
    MatchResult matcher = pattern.exec(mbeanName);
    return matcher.getGroup(1);
}
 
開發者ID:ow2-proactive,項目名稱:scheduling-portal,代碼行數:8,代碼來源:CpusUsageLineChart.java


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