本文整理汇总了Java中classycle.util.StringPattern类的典型用法代码示例。如果您正苦于以下问题:Java StringPattern类的具体用法?Java StringPattern怎么用?Java StringPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringPattern类属于classycle.util包,在下文中一共展示了StringPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCyclesStatement
import classycle.util.StringPattern; //导入依赖的package包/类
private void createCyclesStatement(String[] tokens, int lineNumber) {
final boolean packageCycles = tokens[1].equals(PACKAGE_CYCLES_KEY_WORD);
if (tokens.length != 6) {
throwException("Invalid statement.", lineNumber, tokens.length);
}
if (tokens[2].equals(">") == false) {
throwException("'>' expected.", lineNumber, 2);
}
int size = 0;
try {
size = Integer.parseInt(tokens[3]);
} catch (final NumberFormatException e) {
throwException("Number expected.", lineNumber, 3);
}
if (size < 1) {
throwException("Size has to be >= 1", lineNumber, 3);
}
if (tokens[4].equals(IN_KEY_WORD) == false) {
throwException("'in' expected.", lineNumber, 4);
}
final StringPattern pattern = createPattern(tokens[5], lineNumber, 4);
statements.add(new CheckCyclesStatement(pattern, size, packageCycles, setDefinitions));
}
示例2: createPattern
import classycle.util.StringPattern; //导入依赖的package包/类
private StringPattern createPattern(String term, int lineNumber, int tokenIndex) {
StringPattern pattern = setDefinitions.getPattern(term);
if (pattern == null) {
if (term.startsWith("[") && term.endsWith("]")) {
throwException("Set " + term + " is undefined.", lineNumber, tokenIndex);
}
if (term.indexOf('.') < 0 && term.indexOf('*') < 0 && term.length() > 0
&& Character.isLowerCase(term.charAt(0))) {
throwException(
"Patterns without a '.' and a '*' should not start " + "with a lower-case letter: " + term,
lineNumber, tokenIndex);
}
pattern = new WildCardPattern(term);
}
return pattern;
}
示例3: getLists
import classycle.util.StringPattern; //导入依赖的package包/类
private StringPattern[][] getLists(String[] tokens, int lineNumber, String[] keyWords, int startIndex) {
final ArrayList<StringPattern> startSets = new ArrayList<>();
final ArrayList<StringPattern> endSets = new ArrayList<>();
ArrayList<StringPattern> currentList = startSets;
for (int i = startIndex; i < tokens.length; i++) {
final String token = tokens[i];
if (isAKeyWord(token, keyWords)) {
if (currentList == endSets) {
throwException("Invalid appearance of key word '" + token + "'.", lineNumber, i);
}
currentList = endSets;
} else {
currentList.add(createPattern(token, lineNumber, i));
}
}
final StringPattern[][] result = new StringPattern[2][];
result[0] = startSets.toArray(new StringPattern[0]);
result[1] = endSets.toArray(new StringPattern[0]);
return result;
}
示例4: parseLayerDefinition
import classycle.util.StringPattern; //导入依赖的package包/类
private void parseLayerDefinition(String[] tokens, int lineNumber) {
if (tokens.length < 2) {
throwException("Missing layer name.", lineNumber, 1);
}
final String layerName = tokens[1];
if (layerDefinitions.contains(layerName)) {
throwException("Layer '" + layerName + "' already defined.", lineNumber, 1);
}
checkForEqualCharacter(tokens, lineNumber, 2);
if (tokens.length < 4) {
throwException("Missing terms in definition of layer '" + layerName + "'.", lineNumber, 3);
}
final ArrayList<StringPattern> layer = new ArrayList<>();
for (int i = 3; i < tokens.length; i++) {
layer.add(createPattern(tokens[i], lineNumber, i));
}
final StringPattern[] sets = new StringPattern[layer.size()];
layerDefinitions.put(layerName, layer.toArray(sets));
}
示例5: parseSetDefinition
import classycle.util.StringPattern; //导入依赖的package包/类
private void parseSetDefinition(String[] tokens, int lineNumber) {
final String setName = tokens[0];
if (setName.endsWith("]") == false) {
throwException("Set name has to end with ']'.", lineNumber, 0);
}
if (setDefinitions.contains(setName)) {
throwException("Set " + setName + " already defined.", lineNumber, 0);
}
checkForEqualCharacter(tokens, lineNumber, 1);
final StringPattern[][] lists = getLists(tokens, lineNumber, EXCLUDING, 2);
if (lists[0].length == 0 && lists[1].length == 0) {
throwException("Missing terms in set definition.", lineNumber, 2);
}
final AndStringPattern definition = new AndStringPattern();
if (lists[0].length > 0) {
definition.appendPattern(createOrSequence(lists[0]));
}
if (lists[1].length > 0) {
definition.appendPattern(new NotStringPattern(createOrSequence(lists[1])));
}
setDefinitions.put(setName, definition);
}
示例6: analyseClassFile
import classycle.util.StringPattern; //导入依赖的package包/类
private static void analyseClassFile(File file, String source,
ArrayList<UnresolvedNode> unresolvedNodes,
StringPattern reflectionPattern)
throws IOException
{
if (file.isDirectory())
{
String[] files = file.list();
for (int i = 0; i < files.length; i++)
{
File child = new File(file, files[i]);
if (child.isDirectory() || files[i].endsWith(".class"))
{
analyseClassFile(child, source, unresolvedNodes, reflectionPattern);
}
}
} else
{
unresolvedNodes.add(extractNode(file, source, reflectionPattern));
}
}
示例7: extractNode
import classycle.util.StringPattern; //导入依赖的package包/类
private static UnresolvedNode extractNode(File file, String source,
StringPattern reflectionPattern)
throws IOException
{
InputStream stream = null;
UnresolvedNode result = null;
try
{
stream = new FileInputStream(file);
result = Parser.createNode(stream, source, (int) file.length(),
reflectionPattern);
} finally
{
if (stream != null)
{
try
{
stream.close();
} catch (IOException e) {}
}
}
return result;
}
示例8: DependencyStatement
import classycle.util.StringPattern; //导入依赖的package包/类
public DependencyStatement(StringPattern[] startSets,
StringPattern[] finalSets,
String dependencyType,
SetDefinitionRepository repository,
ResultRenderer renderer)
{
_startSets = startSets;
_finalSets = finalSets;
_dependencyType = dependencyType;
_repository = repository;
_renderer = renderer;
_startConditions = createVertexConditions(startSets);
_finalConditions = createVertexConditions(finalSets);
_finalSet = new OrStringPattern(_finalSets);
_finalCondition = new VertexUnionCondition(_finalConditions);
}
示例9: createPattern
import classycle.util.StringPattern; //导入依赖的package包/类
private StringPattern createPattern(String term, int lineNumber,
int tokenIndex)
{
StringPattern pattern = _setDefinitions.getPattern(term);
if (pattern == null)
{
if (term.startsWith("[") && term.endsWith("]"))
{
throwException("Set " + term + " is undefined.",
lineNumber, tokenIndex);
}
if (term.indexOf('.') < 0 && term.indexOf('*') < 0
&& term.length() > 0 && Character.isLowerCase(term.charAt(0)))
{
throwException("Patterns without a '.' and a '*' should not start "
+ "with a lower-case letter: " + term,
lineNumber, tokenIndex);
}
pattern = new WildCardPattern(term);
}
return pattern;
}
示例10: parseLayerDefinition
import classycle.util.StringPattern; //导入依赖的package包/类
private void parseLayerDefinition(String[] tokens, int lineNumber)
{
if (tokens.length < 2)
{
throwException("Missing layer name.", lineNumber, 1);
}
String layerName = tokens[1];
if (_layerDefinitions.contains(layerName))
{
throwException("Layer '" + layerName + "' already defined.",
lineNumber, 1);
}
checkForEqualCharacter(tokens, lineNumber, 2);
if (tokens.length < 4)
{
throwException("Missing terms in definition of layer '"
+ layerName + "'.", lineNumber, 3);
}
List<StringPattern> layer = new ArrayList<StringPattern>();
for (int i = 3; i < tokens.length; i++)
{
layer.add(createPattern(tokens[i], lineNumber, i));
}
StringPattern[] sets = new StringPattern[layer.size()];
_layerDefinitions.put(layerName, (StringPattern[]) layer.toArray(sets));
}
示例11: createLayeringStatement
import classycle.util.StringPattern; //导入依赖的package包/类
private void createLayeringStatement(String[] tokens, int lineNumber)
{
StringPattern[][] layers = new StringPattern[tokens.length - 2][];
for (int i = 0; i < layers.length; i++)
{
String name = tokens[i + 2];
layers[i] = _layerDefinitions.getLayer(name);
if (layers[i] == null)
{
throwException("Undefined layer '" + name + "'.", lineNumber, i + 2);
}
}
boolean strict = tokens[1].equals(STRICT_LAYERING_OF_KEY_WORD);
_statements.add(new LayeringStatement(layers, strict, _setDefinitions,
_layerDefinitions, _renderer));
}
示例12: createDependencyStatement
import classycle.util.StringPattern; //导入依赖的package包/类
private void createDependencyStatement(String[] tokens, int lineNumber)
{
StringPattern[][] lists = getLists(tokens, lineNumber, INDEPENDENT, 1);
if (lists[0].length == 0)
{
throwException("Missing start sets.", lineNumber, 1);
}
if (lists[1].length == 0)
{
throwException("Missing end sets. Probably one of the following "
+ "key words are missing: "
+ Arrays.asList(INDEPENDENT), lineNumber, tokens.length);
}
_statements.add(new DependencyStatement(lists[0], lists[1], tokens[lists[0].length + 1],
_setDefinitions, _renderer));
}
示例13: checkIntraLayerDependencies
import classycle.util.StringPattern; //导入依赖的package包/类
private void checkIntraLayerDependencies(ResultContainer result,
StringPattern[] patterns,
AtomicVertex[] graph)
{
StringPattern[] startSets = new StringPattern[1];
StringPattern[] endSets = new StringPattern[patterns.length - 1];
for (int i = 0; i < patterns.length; i++)
{
startSets[0] = patterns[i];
System.arraycopy(patterns, 0, endSets, 0, i);
System.arraycopy(patterns, i + 1, endSets, i, patterns.length - i - 1);
DependencyStatement s =
new DependencyStatement(startSets, endSets, DIRECTLY_INDEPENDENT_OF_KEY_WORD,
_repository, _renderer);
result.add(s.execute(graph));
}
}
示例14: analyseClassFile
import classycle.util.StringPattern; //导入依赖的package包/类
private static void analyseClassFile(File file, String source, ArrayList<UnresolvedNode> unresolvedNodes,
StringPattern reflectionPattern) throws IOException {
if (file.isDirectory()) {
final String[] files = file.list();
for (int i = 0; i < files.length; i++) {
final File child = new File(file, files[i]);
if (child.isDirectory() || files[i].endsWith(".class")) {
analyseClassFile(child, source, unresolvedNodes, reflectionPattern);
}
}
} else {
unresolvedNodes.add(extractNode(file, source, reflectionPattern));
}
}
示例15: analyseClassFiles
import classycle.util.StringPattern; //导入依赖的package包/类
private static void analyseClassFiles(ZipFile zipFile, String source, ArrayList<UnresolvedNode> unresolvedNodes,
StringPattern reflectionPattern) throws IOException {
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
final InputStream stream = zipFile.getInputStream(entry);
final int size = (int) entry.getSize();
unresolvedNodes.add(Parser.createNode(stream, source, size, reflectionPattern));
}
}
}