method2testcases
stringlengths
118
6.63k
### Question: Notify extends Message { public static Notify fromJSON(JSONObject json) throws JSONException { Notify e = new Notify(); Message.fromJSON(e, json); e.setEventKey(json.optString("eventKey",null)); e.setDriver(json.optString("driver",null)); e.setInstanceId(json.optString("instanceId",null)); if(json.has("pa...
### Question: DriverDao { public void insert(DriverModel driver) { DriverModel found = retrieve(driver.id(), driver.device()); if (found != null){ removeFromMap(found); } insertOnMap(driver); } DriverDao(InitialProperties bundle); void insert(DriverModel driver); List<DriverModel> list(); List<DriverModel> list(String ...
### Question: DriverManager { public Response handleServiceCall(Call serviceCall, CallContext messageContext) throws DriverManagerException{ DriverModel model = null; if (serviceCall.getInstanceId() != null ){ model = driverDao.retrieve(serviceCall.getInstanceId(),currentDevice.getName()); if (model == null){ logger.se...
### Question: DriverManager { public List<UosDriver> listDrivers(){ List<DriverModel> list = driverDao.list(null,currentDevice.getName()); if (list.isEmpty()) return new ArrayList<UosDriver>(); List<UosDriver> ret = new ArrayList<UosDriver>(); for (DriverModel m : list){ ret.add(instances.get(m.rowid())); } return ret;...
### Question: DriverManager { public void initDrivers(Gateway gateway, InitialProperties properties){ try { if (driverDao.list("uos.DeviceDriver").isEmpty()){ DeviceDriver deviceDriver = new DeviceDriver(); deployDriver(deviceDriver.getDriver(), deviceDriver); } } catch (Exception e) { throw new RuntimeException(e); } ...
### Question: DriverManager { public void tearDown(){ for (DriverModel d : driverDao.list()){ undeployDriver(d.id()); } dCount = 0; } DriverManager(UpDevice currentDevice, DriverDao driverDao, DeviceDao deviceDao, ReflectionServiceCaller serviceCaller); Response handleServiceCall(Call serviceCall, CallContext messageC...
### Question: DriverData { public boolean equals(Object obj) { if (obj != null && obj instanceof DriverData){ DriverData temp = (DriverData)obj; if (temp.driver != null && temp.device != null && temp.instanceID != null){ return temp.driver.equals(this.driver) && temp.device.equals(this.device) && temp.instanceID.equals...
### Question: ApplicationManager { public void add(UosApplication app) { add(app, assignAName(app, null)); } ApplicationManager(InitialProperties properties, Gateway gateway, ConnectionManagerControlCenter connectionManagerControlCenter); void add(UosApplication app); void add(UosApplication app, String id); void st...
### Question: ApplicationManager { public void deploy(UosApplication app) { deploy(app, null); } ApplicationManager(InitialProperties properties, Gateway gateway, ConnectionManagerControlCenter connectionManagerControlCenter); void add(UosApplication app); void add(UosApplication app, String id); void startApplicati...
### Question: EventManager implements NotifyHandler { public void register(UosEventListener listener, UpDevice device, String driver, String instanceId, String eventKey, Map<String,Object> parameters) throws NotifyException{ String eventIdentifier = getEventIdentifier(device, driver, instanceId, eventKey); logger.fine(...
### Question: EventManager implements NotifyHandler { public void notify(Notify notify, UpDevice device) throws NotifyException{ try { if(device == null){ handleNofify(notify, device); }else{ messageEngine.notify(notify, device); } } catch (MessageEngineException e) { throw new NotifyException(e); } } EventManager(Mess...
### Question: EventManager implements NotifyHandler { public void unregister(UosEventListener listener, UpDevice device, String driver, String instanceId, String eventKey) throws NotifyException{ List<ListenerInfo> listeners = findListeners( device, driver, instanceId, eventKey); if (listeners == null){ return; } Notif...
### Question: SmartSpaceGateway implements Gateway { public Response callService(UpDevice device, String serviceName, String driverName, String instanceId, String securityType, Map<String, Object> parameters) throws ServiceCallException { return adaptabilityEngine.callService(device, serviceName, driverName, instanceId...
### Question: SmartSpaceGateway implements Gateway { public void register(UosEventListener listener, UpDevice device, String driver, String eventKey) throws NotifyException { register(listener, device, driver, null,eventKey); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager...
### Question: SmartSpaceGateway implements Gateway { public void notify(Notify notify, UpDevice device) throws NotifyException { adaptabilityEngine.notify(notify, device); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityM...
### Question: SmartSpaceGateway implements Gateway { public void unregister(UosEventListener listener) throws NotifyException { adaptabilityEngine.unregister(listener); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityMana...
### Question: SmartSpaceGateway implements Gateway { public List<DriverData> listDrivers(String driverName) { return driverManager.listDrivers(driverName, null); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityManager, ...
### Question: SmartSpaceGateway implements Gateway { public List<UpDevice> listDevices() { return deviceManager.listDevices(); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityManager, DeviceManager deviceManager, Drive...
### Question: DeviceDriver implements UosDriver { @Override public UpDriver getDriver() { return driver; } DeviceDriver(); @Override UpDriver getDriver(); @Override void init(Gateway gateway, InitialProperties properties, String instanceId); @Override void destroy(); @Override List<UpDriver> getParent(); @SuppressWarni...
### Question: Notify extends Message { @Override public boolean equals(Object obj) { if (obj == null){ return false; } if (!( obj instanceof Notify)){ return false; } Notify temp = (Notify) obj; if(!compare(this.eventKey,temp.eventKey)) return false; if(!compare(this.driver,temp.driver)) return false; if(!compare(this....
### Question: MessageHandler { public void notifyEvent(Notify notify, UpDevice device) throws MessageEngineException{ if ( device == null || notify == null || notify.getDriver() == null || notify.getDriver().isEmpty() || notify.getEventKey() == null || notify.getEventKey().isEmpty()){ throw new IllegalArgumentException...
### Question: UpDriver { @Override public boolean equals(Object obj) { if (obj == null || ! (obj instanceof UpDriver) ) return false; UpDriver d = (UpDriver) obj; if(!compare(this.name,d.name)) return false; if(!compare(this.services,d.services)) return false; if(!compare(this.events,d.events)) return false; return tru...
### Question: UpDriver { @Override public int hashCode() { if(name != null){ return name.hashCode(); } return super.hashCode(); } UpDriver(); UpDriver(String name); String getName(); void setName(String name); List<UpService> getServices(); void setServices(List<UpService> services); UpService addService(UpService ser...
### Question: UpDriver { public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put("name", this.getName()); addServices(json, "services", this.services); addServices(json, "events", this.events); addStrings(json, "equivalent_drivers", equivalentDrivers); return json; } UpDriver(); ...
### Question: UpDriver { public static UpDriver fromJSON(JSONObject json) throws JSONException { UpDriver d = new UpDriver(json.optString("name",null)); d.services = addServices(json, "services"); d.events = addServices(json, "events"); d.equivalentDrivers = addStrings(json, "equivalent_drivers"); return d; } UpDriver(...
### Question: UpDevice { @Override public boolean equals(Object obj) { if (obj == null || ! (obj instanceof UpDevice) ){ return false; } UpDevice d = (UpDevice) obj; if(!compare(this.name,d.name)) return false; if(!compare(this.networks,d.networks)) return false; if(!compare(this.meta,d.meta)) return false; return true...
### Question: UpDevice { @Override public int hashCode() { if(name != null){ return name.hashCode(); } return super.hashCode(); } UpDevice(); UpDevice(String name); UpDevice addNetworkInterface(String networkAdress, String networkType); String getName(); void setName(String name); List<UpNetworkInterface> getNetworks(...
### Question: UpDevice { public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put("name", this.name); addNetworks(json, "networks"); addMeta(json); return json; } UpDevice(); UpDevice(String name); UpDevice addNetworkInterface(String networkAdress, String networkType); String getN...
### Question: UpDevice { public static UpDevice fromJSON(JSONObject json) throws JSONException { UpDevice device = new UpDevice(); device.name = json.optString("name", null); device.networks = fromNetworks(json, "networks"); device.meta = fromMeta(json); return device; } UpDevice(); UpDevice(String name); UpDevice add...
### Question: DeviceDao { public void save(UpDevice device) { if (device.getNetworks() != null){ for (UpNetworkInterface ni : device.getNetworks()){ interfaceMap.put(createInterfaceKey(ni), device); if(!networkTypeMap.containsKey(ni.getNetType())){ networkTypeMap.put(ni.getNetType(), new ArrayList<UpDevice>()); } netwo...
### Question: DeviceManager implements RadarListener { public void registerDevice(UpDevice device) { deviceDao.save(device); } DeviceManager(UpDevice currentDevice, DeviceDao deviceDao, DriverDao driverDao, ConnectionManagerControlCenter connectionManagerControlCenter, ConnectivityManager connectivityManager, ...
### Question: Notify extends Message { @Override public int hashCode() { int hash = 0; if (this.eventKey != null){ hash += this.eventKey.hashCode(); } if (this.driver != null){ hash += this.driver.hashCode(); } if (this.instanceId != null){ hash += this.instanceId.hashCode(); } return hash; } Notify(); Notify(String e...
### Question: Notify extends Message { public JSONObject toJSON() throws JSONException { JSONObject json = super.toJSON(); json.put("eventKey",this.eventKey); json.put("driver",this.driver); json.put("instanceId",this.instanceId); if (this.parameters != null) json.put("parameters",this.parameters); return json; } Notif...
### Question: StringUtils { static boolean contains(char c, String what) { return what.indexOf(c) >= 0; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(StringBuilder s, String c); static String ...
### Question: StringUtils { public static String strip(StringBuilder s, String what) { int start = skip_char(s, what, 0); int end = skip_char_reverse(s, what, s.length() - 1); if (start > end) return s.substring(start); return s.substring(start, end + 1); } static int skip_spaces_reverse(StringBuilder s, int pos); sta...
### Question: StringUtils { public static void set_defaultAutoLineLenght(int length) { defaultAutoLineLength = length; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(StringBuilder s, String c);...
### Question: StringUtils { public static int get_defaultAutoLineLenght() { return defaultAutoLineLength; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(StringBuilder s, String c); static Strin...
### Question: StringUtils { public static String formatDouble(double d, int rounding) { return formatDouble(Rounding.rndDouble(d, rounding)); } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(Stri...
### Question: StringUtils { public static boolean isYes(String maybe_a_yes_value) { if (maybe_a_yes_value == null) { return false; } if (maybe_a_yes_value.equalsIgnoreCase("ja")) { return true; } if (maybe_a_yes_value.equalsIgnoreCase("yes")) { return true; } if (maybe_a_yes_value.equalsIgnoreCase("true")) { return tru...
### Question: StringUtils { @Deprecated public static String exceptionToString(Exception ex) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); PrintStream s = new PrintStream(bos); ex.printStackTrace(s); s.flush(); return bos.toString(); } static int skip_spaces_reverse(StringBuilder s, int pos); static int s...
### Question: StringUtils { public static String skipLeadingLines(String sourceString, int lines) { if (lines <= 0) return sourceString; String truncatedString; int lbCounter = 0; int idx = 0; char[] arr = sourceString.toCharArray(); for (idx = 0; idx < arr.length; idx++) { if (lbCounter == lines) { break; } if (arr[id...
### Question: StringUtils { static int skip_char(StringBuilder s, String what, int pos) { while (pos <= (s.length() - 1)) { char c; c = s.charAt(pos); if (contains(c, what)) { pos++; continue; } break; } return pos; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int...
### Question: StringUtils { public static String byteArrayToString(byte[] data) { if (data == null) { return ""; } StringBuilder str = new StringBuilder(); for (int index = 0; index < data.length; index++) { str.append((char) (data[index])); } return str.toString(); } static int skip_spaces_reverse(StringBuilder s, in...
### Question: ParseJNLP { public Properties getProperties() { return properties; } ParseJNLP( File file ); Properties getProperties(); String getMainJar(); List<String> getJars(); String getCodeBase(); String print(); void print( StringBuilder stream, Node node, int depth ); static void main( final String[] argv); }##...
### Question: ParseJNLP { public String getMainJar() { return mainJar; } ParseJNLP( File file ); Properties getProperties(); String getMainJar(); List<String> getJars(); String getCodeBase(); String print(); void print( StringBuilder stream, Node node, int depth ); static void main( final String[] argv); }### Answer: ...
### Question: ParseJNLP { public List<String> getJars() { return jars; } ParseJNLP( File file ); Properties getProperties(); String getMainJar(); List<String> getJars(); String getCodeBase(); String print(); void print( StringBuilder stream, Node node, int depth ); static void main( final String[] argv); }### Answer: ...
### Question: ParseJNLP { public String getCodeBase() { return codeBase; } ParseJNLP( File file ); Properties getProperties(); String getMainJar(); List<String> getJars(); String getCodeBase(); String print(); void print( StringBuilder stream, Node node, int depth ); static void main( final String[] argv); }### Answer...
### Question: BaseHolidays { public static LocalDate getEaster( int year ) { Easterformular easter_formular = new Easterformular(year); int day = easter_formular.easterday(); if( day <= 31 ) { return new LocalDate( year, 3, day ); } else { return new LocalDate( year, 4, day - 31 ); } } BaseHolidays( String CountryCode ...
### Question: BaseHolidays { public LocalDate getEuropeanSummerTimeBegin( int year ) { return getLastSundayOf( year, 3 ); } BaseHolidays( String CountryCode ); HolidayInfo create( DateMidnight date, boolean floating, boolean official, String name ); HolidayInfo create( LocalDate date, boolean floating, boolean official...
### Question: BaseHolidays { public LocalDate getEuropeanSummerTimeEnd( int year ) { return getLastSundayOf( year, 10 ); } BaseHolidays( String CountryCode ); HolidayInfo create( DateMidnight date, boolean floating, boolean official, String name ); HolidayInfo create( LocalDate date, boolean floating, boolean official,...
### Question: BaseHolidays { public LocalDate getLastSundayOf( int year, int month ) { LocalDate dm = new LocalDate( year, month, 31 ); while( true ) { if( dm.getDayOfWeek() == DateTimeConstants.SUNDAY ) return dm; dm = dm.minusDays(1); } } BaseHolidays( String CountryCode ); HolidayInfo create( DateMidnight date, bool...
### Question: DBString extends DBValue { @Override public DBDataType getDBType() { return DBDataType.DB_TYPE_STRING; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBT...
### Question: StringUtils { static int skip_char_reverse(StringBuilder s, String what, int pos) { while (pos > 0) { char c; c = s.charAt(pos); if (contains(c, what)) { pos--; continue; } break; } return pos; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); s...
### Question: DBString extends DBValue { @Override public void loadFromDB(Object obj) { value = (String)obj; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @...
### Question: DBString extends DBValue { @Override public String getValue() { return value; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Override void loa...
### Question: DBString extends DBValue { @Override public String toString() { return value; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Override void loa...
### Question: DBString extends DBValue { @Override public void loadFromString(String s) { value = s; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Override...
### Question: DBString extends DBValue { @Override public boolean acceptString(String s) { if( s.length() > max_len ) return false; return true; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase );...
### Question: DBString extends DBValue { @Override public DBString getCopy() { DBString s = new DBString( name, title, max_len ); s.value = value; return s; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_...
### Question: DBString extends DBValue { @Override public void loadFromCopy(Object obj) { value = (String)obj; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType();...
### Question: DBString extends DBValue { public int getMaxLen() { return max_len; } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Override void loadFromDB(Ob...
### Question: DBString extends DBValue { public boolean isEmpty() { return value.isEmpty(); } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Override void loa...
### Question: DBString extends DBValue { public boolean isEmptyTrimmed() { return value.trim().isEmpty(); } DBString( String name, int max_len ); DBString( String name, String title, int max_len ); DBString( String name, String title, int max_len, boolean is_already_lowercase ); @Override DBDataType getDBType(); @Ove...
### Question: StringUtils { public static int skip_spaces_reverse(StringBuilder s, int pos) { return skip_char_reverse(s, " \t\n\r", pos); } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(StringB...
### Question: StringUtils { public static int skip_spaces(StringBuilder s, int pos) { return skip_char(s, " \t\n\r", pos); } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> split_str(StringBuilder s, String...
### Question: StringUtils { public static boolean is_space(char c) { if (c == ' ' || c == '\t' || c == '\n' || c == '\r') { return true; } return false; } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c); static List<String> spl...
### Question: StringUtils { public static List<String> split_str(StringBuilder s, String c) { List<String> res = new ArrayList<>(); int start = 0; do { int pos = s.indexOf(c, start); if (pos < 0) { res.add(s.substring(start)); break; } res.add(s.substring(start, pos)); start = pos + 1; } while (start > 0); return res; ...
### Question: StringUtils { public static String strip_post(StringBuilder s, String what) { int end = skip_char_reverse(s, what, s.length() - 1); return s.substring(0, end + 1); } static int skip_spaces_reverse(StringBuilder s, int pos); static int skip_spaces(StringBuilder s, int pos); static boolean is_space(char c)...
### Question: NetworkStatusPresenter implements NetworkStatusContract.Presenter { @Override public void getNodes() { stopNodeRefresh(); startNodeRefresh(); } NetworkStatusPresenter(NetworkStatusContract.View view, Feature6LoWPANProtocol centralNode); @Override void startNodeRefresh(); @Override void stopNodeRefresh(); ...
### Question: Feature6LoWPANProtocol extends Feature { public boolean getNetworkNodeList(NetworkNodeListCallback callback) { Log.d("6lowpan","getNetworkNodeList: "+mRequestTimeout); if(mRequestTimeout !=null) return false; mNodeListCallback = callback; getParentNode().enableNotification(this); mNetworkResponse = new Ne...
### Question: Feature6LoWPANProtocol extends Feature { public boolean getNodeStatus(SensorNode node, NodeStatusCallback callback){ Log.d("6lowpan","getNodeStatus: "+mRequestTimeout); if(mRequestTimeout !=null) return false; mNodeStatusCallback = new PrivateNodeStatusCallback(node,callback); getParentNode().enableNotifi...
### Question: Feature6LoWPANProtocol extends Feature { public boolean updateLedDimming(NetworkAddress address,byte dimmingValue,LedStatusChangeCallback callback) { Log.d("6lowpan","update dimming: "+mRequestTimeout); if(mRequestTimeout !=null) return false; byte payload[] = new byte[10]; System.arraycopy(address.getByt...
### Question: GetSensorNodeListParser { public static @Nullable List<SensorNode> parse(byte[] responsePayload){ int nNodes = responsePayload[0]; if(responsePayload.length!=nNodes*NetworkAddress.ADDRESS_LENGTH+1) return null; ArrayList<SensorNode> nodes = new ArrayList<>(nNodes); for(int i=0;i<nNodes;i++){ byte rawAddre...
### Question: NetworkResponse { public void append(@NonNull byte[] bytes) { for(byte b : bytes){ mData.add(b); } } void append(@NonNull byte[] bytes); short getTimestamp(); short getCommandId(); short getLength(); boolean isCompleted(); byte[] getPayload(); }### Answer: @Test public void theByteAreAppendedToTheRespon...
### Question: InitializerMessageSource extends AbstractMessageSource implements MutableMessageSource, ApplicationContextAware { public Locale getLocaleFromFileBaseName(String baseName) throws IllegalArgumentException { String[] parts = baseName.split("_"); if (parts.length == 1) { throw new IllegalArgumentException( "'...
### Question: NestedConceptLineProcessor extends ConceptLineProcessor { public Concept fill(Concept concept, CsvLine line) throws IllegalArgumentException { if (!CollectionUtils.isEmpty(concept.getAnswers())) { concept.getAnswers().clear(); } String childrenStr; childrenStr = line.get(HEADER_ANSWERS); if (!StringUtils....
### Question: OrderTypeLineProcessor extends BaseLineProcessor<OrderType> { @Override public OrderType fill(OrderType orderType, CsvLine line) throws IllegalArgumentException { orderType.setName(line.get(HEADER_NAME)); orderType.setDescription(line.getString(HEADER_DESC, "")); String javaClassName = line.getString(JAVA...
### Question: LocationLineProcessor extends BaseLineProcessor<Location> { @Override public Location fill(Location loc, CsvLine line) throws IllegalArgumentException { loc.setName(line.get(HEADER_NAME)); loc.setDescription(line.get(HEADER_DESC)); loc.setParentLocation(null); String parentId = line.getString(HEADER_PAREN...
### Question: OrderableCsvFile implements Comparable<OrderableCsvFile> { public File getFile() { return file; } OrderableCsvFile(File file, String checksum); Integer getOrder(); String getChecksum(); File getFile(); @Override int compareTo(OrderableCsvFile that); }### Answer: @Test public void shouldSortAccordingToCsv...
### Question: BaseLineProcessor { public static String getVersion(String[] headerLine) throws IllegalArgumentException { return getMetadataValue(headerLine, VERSION_LHS); } abstract T fill(T instance, CsvLine line); static Boolean getVoidOrRetire(CsvLine line); static Map<String, Integer> createIndexMap(String[] heade...
### Question: BaseLineProcessor { public static Map<String, Integer> createIndexMap(String[] headerLine) throws IllegalArgumentException { if (headerLine == null) { throw new IllegalArgumentException("The CSV header line cannot be null."); } Map<String, Integer> indexMap = new HashMap<String, Integer>(); int col = 0; f...
### Question: MappingsConceptLineProcessor extends ConceptLineProcessor { public Concept fill(Concept concept, CsvLine line) throws IllegalArgumentException { if (!CollectionUtils.isEmpty(concept.getConceptMappings())) { concept.getConceptMappings().clear(); } String mappingsStr = line.get(HEADER_MAPPINGS_SAMEAS); if (...
### Question: ConceptNumericLineProcessor extends ConceptLineProcessor { public Concept fill(Concept instance, CsvLine line) throws IllegalArgumentException { if (!DATATYPE_NUMERIC.equals(line.get(ConceptLineProcessor.HEADER_DATATYPE))) { return instance; } ConceptNumeric cn = new ConceptNumeric(instance); if (instance...
### Question: MealyFilter { @SafeVarargs public static <I, O> CompactMealy<I, O> pruneTransitionsWithOutput(MealyMachine<?, I, ?, O> in, Alphabet<I> inputs, O... outputs) { return pruneTransitionsWithOutput(in, inputs, Arrays.asList(outputs)); } private MealyFilter(); @SafeVarargs static CompactMealy<I, O> pruneTransi...
### Question: DFAs { public static <I> CompactDFA<I> xor(DFA<?, I> dfa1, DFA<?, I> dfa2, Alphabet<I> inputAlphabet) { return xor(dfa1, dfa2, inputAlphabet, new CompactDFA<>(inputAlphabet)); } private DFAs(); static CompactDFA<I> combine(DFA<?, I> dfa1, DFA<?, I> dfa2, ...
### Question: DFAs { public static <I> CompactDFA<I> equiv(DFA<?, I> dfa1, DFA<?, I> dfa2, Alphabet<I> inputAlphabet) { return equiv(dfa1, dfa2, inputAlphabet, new CompactDFA<>(inputAlphabet)); } private DFAs(); static CompactDFA<I> combine(DFA<?, I> dfa1, DFA<?, I> dfa2, ...
### Question: DFAs { public static <I> CompactDFA<I> impl(DFA<?, I> dfa1, DFA<?, I> dfa2, Alphabet<I> inputAlphabet) { return impl(dfa1, dfa2, inputAlphabet, new CompactDFA<>(inputAlphabet)); } private DFAs(); static CompactDFA<I> combine(DFA<?, I> dfa1, DFA<?, I> dfa2, ...
### Question: DFAs { public static <I> CompactDFA<I> complement(DFA<?, I> dfa, Alphabet<I> inputAlphabet) { return complement(dfa, inputAlphabet, new CompactDFA<>(inputAlphabet)); } private DFAs(); static CompactDFA<I> combine(DFA<?, I> dfa1, DFA<?, I> dfa2, ...
### Question: DFAs { public static <S, I> boolean isPrefixClosed(DFA<S, I> dfa, Alphabet<I> alphabet) { return dfa.getStates() .parallelStream() .allMatch(s -> dfa.isAccepting(s) || alphabet.parallelStream().noneMatch(i -> dfa.isAccepting(dfa.getSuccessors(s, i)))); } private DFAs(); static CompactDFA<I> combine(DFA<?...
### Question: DFAs { public static <S> boolean acceptsEmptyLanguage(DFA<S, ?> dfa) { return dfa.getStates().stream().noneMatch(dfa::isAccepting); } private DFAs(); static CompactDFA<I> combine(DFA<?, I> dfa1, DFA<?, I> dfa2, Alphab...
### Question: Graphs { public static <N, E> Mapping<N, @Nullable Collection<E>> incomingEdges(final Graph<N, E> graph) { if (graph instanceof BidirectionalGraph) { final BidirectionalGraph<N, E> bdGraph = (BidirectionalGraph<N, E>) graph; return bdGraph::getIncomingEdges; } MutableMapping<N, @Nullable Collection<E>> in...
### Question: IntRange extends AbstractList<Integer> implements ArrayWritable<Integer>, RandomAccess, Serializable { @Override public int size() { return size; } IntRange(int start, int end); IntRange(int start, int end, int step); @Override Integer get(int index); int intGet(int index); int intValue(int i); @Overrid...
### Question: IntRange extends AbstractList<Integer> implements ArrayWritable<Integer>, RandomAccess, Serializable { @Override public Integer get(int index) { return Integer.valueOf(intGet(index)); } IntRange(int start, int end); IntRange(int start, int end, int step); @Override Integer get(int index); int intGet(int...
### Question: IntRange extends AbstractList<Integer> implements ArrayWritable<Integer>, RandomAccess, Serializable { @Override public IntRangeIterator iterator() { return new IntRangeIterator(start, step, size); } IntRange(int start, int end); IntRange(int start, int end, int step); @Override Integer get(int index); ...
### Question: MealyMachines { public static <I, O1, O2> CompactMealy<I, Pair<O1, O2>> combine(MealyMachine<?, I, ?, O1> mealy1, MealyMachine<?, I, ?, O2> mealy2, Alphabet<I> inputAlphabet) { return combine(mealy1, mealy2, inputAlphabet, new CompactMealy<>(inputAlphabet)); } private MealyMachines(); static CompactMealy...
### Question: ReusableIterator implements Iterable<T> { @Override public Iterator<T> iterator() { return new CopyOnReadIterator(this.iterator); } ReusableIterator(Iterator<T> iterator); ReusableIterator(Iterator<T> iterator, List<T> cache); @Override Iterator<T> iterator(); }### Answer: @Test public void testIterator...
### Question: CharRange extends AbstractList<Character> implements ArrayWritable<Character>, RandomAccess, Serializable { @Override public CharRangeIterator listIterator() { return new CharRangeIterator(delegate.listIterator()); } CharRange(char low, char high); CharRange(char low, char high, int step); CharRange(Int...
### Question: StringUtil { public static String enquote(String s) { StringBuilder sb = new StringBuilder(s.length() + 2); try { enquote(s, sb); } catch (IOException e) { LOGGER.error("Could not enquote String", e); } return sb.toString(); } private StringUtil(); static String enquote(String s); static void enquote(Str...
### Question: StringUtil { public static String enquoteIfNecessary(String s) { StringBuilder sb = new StringBuilder(); try { enquoteIfNecessary(s, sb); return sb.toString(); } catch (IOException ex) { throw new AssertionError("StringBuilder should not throw", ex); } } private StringUtil(); static String enquote(String...
### Question: StringUtil { public static String unquote(String s) { if (s.length() < 2) { throw new IllegalArgumentException( "Argument to StringUtil.unquote() must begin and end with a double quote ('\"')."); } StringBuilder sb = new StringBuilder(s.length() - 2); try { unquote(s, sb); } catch (IOException e) { LOGGER...