Ignore:
Timestamp:
01/16/13 17:51:51 (11 years ago)
Author:
adeicke
Message:
  • Removed lombok related annotations and util class
  • Added comments and formating due to match project defaults
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/util/TextInputUtil.java

    r1031 r1040  
     1//   Copyright 2012 Georg-August-Universität Göttingen, Germany 
     2// 
     3//   Licensed under the Apache License, Version 2.0 (the "License"); 
     4//   you may not use this file except in compliance with the License. 
     5//   You may obtain a copy of the License at 
     6// 
     7//       http://www.apache.org/licenses/LICENSE-2.0 
     8// 
     9//   Unless required by applicable law or agreed to in writing, software 
     10//   distributed under the License is distributed on an "AS IS" BASIS, 
     11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
     12//   See the License for the specific language governing permissions and 
     13//   limitations under the License. 
     14 
    115package de.ugoe.cs.autoquest.usability.util; 
    216 
     
    1529import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    1630 
     31/** 
     32 * <p> 
     33 * TODO comment 
     34 * </p> 
     35 *  
     36 * @author Alexander Deicke 
     37 */ 
    1738public class TextInputUtil { 
    18      
    19     public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) { 
     39 
     40    private TextInputUtil() { 
     41        // util class 
     42    } 
     43 
     44    public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) 
     45    { 
    2046        List<Iterable<String>> allTextInputs = Lists.newArrayList(); 
    21         for(ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) { 
     47        for (ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) { 
    2248            TextInput textInput = (TextInput) ((IEventTask) nodeWithTextInput).getEventType(); 
    2349            allTextInputs.add(splitTextIntoWordsAndSigns(textInput.getEnteredText())); 
     
    2551        return HashMultiset.create(Iterables.concat(allTextInputs)); 
    2652    } 
    27      
     53 
    2854    public static Iterable<String> splitTextIntoWordsAndSigns(String enteredText) { 
    29         CharMatcher onlyWords = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate())); 
    30         CharMatcher onlySigns = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 
    31         Iterable<String> words = Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 
    32         Iterable<String> signs = Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 
     55        CharMatcher onlyWords = 
     56            CharMatcher.WHITESPACE.or(CharMatcher 
     57                .forPredicate(characterIsJavaIdentifierPartPredicate())); 
     58        CharMatcher onlySigns = 
     59            CharMatcher.WHITESPACE.or(CharMatcher 
     60                .forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 
     61        Iterable<String> words = 
     62            Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 
     63        Iterable<String> signs = 
     64            Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 
    3365        return Iterables.concat(words, signs); 
    3466    } 
    35      
     67 
    3668    public static Predicate<Character> characterIsJavaIdentifierPartPredicate() { 
    3769        return new Predicate<Character>() { 
    38              
     70 
    3971            @Override 
    4072            public boolean apply(Character character) { 
    41                return !Character.isJavaIdentifierPart(character); 
     73                return !Character.isJavaIdentifierPart(character); 
    4274            } 
    43              
     75 
    4476        }; 
    4577    } 
    46      
     78 
    4779    public static Predicate<Character> characterIsLetterOrDigitPredicate() { 
    4880        return new Predicate<Character>() { 
    49              
     81 
    5082            @Override 
    5183            public boolean apply(Character character) { 
    5284                return !Character.isLetterOrDigit(character); 
    5385            } 
    54              
     86 
    5587        }; 
    5688    } 
Note: See TracChangeset for help on using the changeset viewer.