method2testcases
stringlengths
118
3.08k
### Question: GeneralizedTime implements Comparable<GeneralizedTime> { public Date getDate() { return calendar.getTime(); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneral...
### Question: ObjectClass extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } ObjectClass( String oid ); List<String> getMayAttributeTypeOids(); List<AttributeType> getMayAttributeTypes(); void addMayAttributeTypeOids( String... oid...
### Question: OidRegistry implements Iterable<T> { public OidRegistry<T> copy() { OidRegistry<T> copy = new OidRegistry<>(); copy.byOid = new HashMap<>(); return copy; } boolean contains( String oid ); String getPrimaryName( String oid ); T getSchemaObject( String oid ); List<String> getNameSet( String oid ); Iterator...
### Question: DitStructureRule extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } DitStructureRule( int ruleId ); String getForm(); void setForm( String form ); int getRuleId(); void setRuleId( int ruleId ); List<Integer> getSuperR...
### Question: BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String val...
### Question: SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( Sche...
### Question: PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } private PrepareString(); static String transcode( byte[] bytes ); static String normaliz...
### Question: MatchingRuleUse extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } MatchingRuleUse( String oid ); List<String> getApplicableAttributeOids(); List<AttributeType> getApplicableAttributes(); void setApplicableAttributeOi...
### Question: Ava implements Externalizable, Cloneable, Comparable<Ava> { public String getName() { return upName; } Ava(); Ava( SchemaManager schemaManager ); Ava( SchemaManager schemaManager, Ava ava ); Ava( String upType, byte[] upValue ); Ava( SchemaManager schemaManager, String upType, byte[] upValue ); Ava( ...
### Question: Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { @Override public String toString() { return upName == null ? "" : upName; } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( String rdn ); Rdn( SchemaManager schemaManager, String ...
### Question: Oid { public static boolean isOid( String oidString ) { try { Oid.fromString( oidString ); return true; } catch ( DecoderException e ) { return false; } } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromSt...
### Question: Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public String getType() { switch ( nbAvas ) { case 0: return null; case 1: return ava.getType(); default: return avas.get( 0 ).getType(); } } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn...
### Question: Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public int size() { return nbAvas; } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( String rdn ); Rdn( SchemaManager schemaManager, String upType, String upValue ); Rdn( String ...
### Question: LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifE...
### Question: LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } private LdifRe...
### Question: OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == ...
### Question: Unicode { public static char bytesToChar( byte[] bytes ) { return bytesToChar( bytes, 0 ); } private Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); sta...
### Question: BitString { public boolean getBit( int pos ) { if ( pos > nbBits ) { throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_00002_CANNOT_FIND_BIT, pos, nbBits ) ); } int posBytes = pos >>> 3; int bitNumber = 7 - pos % 8; byte mask = ( byte ) ( 1 << bitNumber ); int res = bytes[posBytes] & mask; return re...
### Question: UnaryFilter extends AbstractFilter { public static UnaryFilter not() { return new UnaryFilter(); } private UnaryFilter(); static UnaryFilter not(); static UnaryFilter not( Filter filter ); @Override StringBuilder build( StringBuilder builder ); }### Answer: @Test public void testNot() { AttributeDescrip...
### Question: SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter and( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.AND ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filte...
### Question: SetOfFiltersFilter extends AbstractFilter { public static SetOfFiltersFilter or( Filter... filters ) { return new SetOfFiltersFilter( FilterOperator.OR ).addAll( filters ); } private SetOfFiltersFilter( FilterOperator operator ); SetOfFiltersFilter add( Filter filter ); SetOfFiltersFilter addAll( Filter....
### Question: FilterBuilder { public static MatchingRuleAssertionFilterBuilder extensible( String value ) { return new MatchingRuleAssertionFilterBuilder( null, value ); } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, Str...
### Question: FilterBuilder { FilterBuilder( Filter filter ) { this.filter = filter; } FilterBuilder( Filter filter ); static FilterBuilder and( FilterBuilder... filters ); static FilterBuilder approximatelyEqual( String attribute, String value ); static FilterBuilder equal( String attribute, String value ); static Mat...
### Question: MatchingRuleAssertionFilter extends AbstractFilter { public static MatchingRuleAssertionFilter extensible( String value ) { return new MatchingRuleAssertionFilter( null, value, FilterOperator.EXTENSIBLE_EQUAL ); } MatchingRuleAssertionFilter( String attribute, String value, FilterOperator operato...
### Question: AttributeDescriptionFilter extends AbstractFilter { public static AttributeDescriptionFilter present( String attribute ) { return new AttributeDescriptionFilter( attribute ); } private AttributeDescriptionFilter( String attribute ); static AttributeDescriptionFilter present( String attribute ); @Override...
### Question: JarLdifSchemaLoader extends AbstractSchemaLoader { public JarLdifSchemaLoader() throws IOException, LdapException { initializeSchemas(); } JarLdifSchemaLoader(); @Override List<Entry> loadComparators( Schema... schemas ); @Override List<Entry> loadSyntaxCheckers( Schema... schemas ); @Override List<Entry>...
### Question: Hex { public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( ...
### Question: Asn1Buffer2 { public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } Asn1Buffer2(); int getPos(); void put( byte b ); void put( byte[] bytes ); byte[] getBytes(); int getSize(); void clear(); @Override String toString(); }### Answer: @Test @Disable...
### Question: DnNode { public synchronized boolean isLeaf() { return !hasChildren(); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized ...
### Question: DnNode { public synchronized N getElement() { return nodeElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boole...
### Question: DnNode { public synchronized boolean hasElement() { return nodeElement != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); sync...
### Question: DnNode { public synchronized boolean hasParent() { return parent != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchroniz...
### Question: MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem...
### Question: SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, ...
### Question: Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p....
### Question: ExecutionContext { public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } ExecutionContext(); ExecutionContext(OutputDefinitionType output); ExecutionContext(List< ? extends OutputDefinitionType> outputs); String getTempDirectoryPath(); List<OutputDefinitionType> getOutput...
### Question: InputHandler { InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } private InputHandler(Builder...
### Question: ExecuteRequest extends Request implements IObserver { public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1....
### Question: OutputDataItem extends ResponseData { public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output...
### Question: MainViewModel extends AndroidViewModel { void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId...
### Question: MainViewModel extends AndroidViewModel { void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); }### Answer:...
### Question: MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisc...
### Question: MainViewModel extends AndroidViewModel { @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } MainViewModel(@NonNull A...
### Question: RightMeshConnector implements MeshStateListener { @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED...
### Question: RightMeshConnector implements MeshStateListener { public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void ...
### Question: RightMeshConnector implements MeshStateListener { public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); vo...
### Question: RightMeshConnector implements MeshStateListener { public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.g...
### Question: SecretSantaFinder { public Map<String, String> pair() { List<Family> families = new ArrayList<Family>(); if(2*maxFamilyMembers > totalNames){ return null; } for(String key: familyMembers.keySet()) { families.add(familyMembers.get(key)) ; } Collections.sort(families); List<String> receiveList = new ArrayLi...
### Question: CyclicWordsKata { public List<List<String>> process() { List<List<String>> processed = new ArrayList<List<String>>(); Map<Integer,List<String>> buckets ; List<List<String>> returnArray ; buckets = separateInputBySize(_input); if(buckets == null) return processed; for(int size: buckets.keySet()) { List<Str...
### Question: ParseRomanNumerals { public String parse() { String returnValue = ""; String prefix = ""; String suffix = ""; while(_input/1000 > 0 ) { int current = _input/1000; int toBeParsed = _input%1000; returnValue = prefix + parseUnder1000(toBeParsed) + suffix + returnValue; _input = current; prefix += "("; suffix...
### Question: StateMachine { public String execute(String input) { String startState = entryState; for(int i = 0; i < input.length();i++){ char event = input.charAt(i) ; if(_symbols.indexOf(event) < 0) { return null; } String key = startState + "_" + event; if (endStates.containsKey(key)) { startState = endStates.get(k...
### Question: ShellMode { public static ShellMode from(String... arguments) { if (runInBatchMode(arguments)) { return new BatchMode(extractCommand(arguments)); } return new InteractiveMode(); } static String usage(); static ShellMode from(String... arguments); static ShellMode batch(String command); static ShellMode i...
### Question: Script extends ShellCommand implements Iterable<ShellCommand> { public Script(List<ShellCommand> commands) { this.commands = new ArrayList<ShellCommand>(commands); } Script(List<ShellCommand> commands); @Override void execute(ShellCommandHandler handler); Iterator<ShellCommand> iterator(); @Override int h...
### Question: AuthResource { public TempTokenResponse temporaryAuthToken(String scope) throws StorageException, UnsupportedEncodingException { if (Strings.isNullOrEmpty(scope)) { scope = "all"; } String tempToken = sessionManager.storeNewTempToken(); String xanauthURL = "xanauth: + URLEncoder.encode(scope, "UTF-8"); Te...
### Question: ApplyOverlayOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ApplyOverlayOp other = (ApplyOverlayOp) obj; if (!linkTypes.equals(other.linkTypes)) return false; if (!variantSpan....
### Question: RopeUtils { public static <T extends StreamElement> Node<T> findSearchNode(Node<T> x, long weight, Node<T> root) { if (root == null) { throw new IllegalArgumentException("root is null"); } if (x == null) { return root; } if (x.weight > weight) { return x; } return findSearchNode(x.parent, weight, root); }...
### Question: DefaultOulipoMachine implements OulipoMachine { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { return iStream.append(text); } DefaultOulipoMachine(StreamLoader stream, RemoteFileManager remoteFileManager, String documentHash, Key privateKey); static Defa...
### Question: DefaultOulipoMachine implements OulipoMachine { @Override public String getText(InvariantSpan invariantSpan) throws IOException { assertSpanNotNull(invariantSpan); return iStream.getText(invariantSpan); } DefaultOulipoMachine(StreamLoader stream, RemoteFileManager remoteFileManager, String documentHash, ...
### Question: DefaultOulipoMachine implements OulipoMachine { @Override public void moveVariant(long to, VariantSpan variantSpan) throws MalformedSpanException, IOException { assertGreaterThanZero(to); assertSpanNotNull(variantSpan); vStream.move(to, variantSpan); oStream.move(to, variantSpan); if (writeDocFile) { docu...
### Question: ApplyOverlayOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + linkTypes.hashCode(); result = prime * result + variantSpan.hashCode(); return result; } ApplyOverlayOp(DataInputStream dis); ApplyOverlayOp(VariantSpan variantSpan...
### Question: SwapVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(...
### Question: SwapVariantOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; SwapVariantOp other = (SwapVariantOp) obj; if (!v1.equals(other.v1)) return false; if (!v2.equals(other.v2)) return f...
### Question: SwapVariantOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + v1.hashCode(); result = prime * result + v2.hashCode(); return result; } SwapVariantOp(DataInputStream dis); SwapVariantOp(VariantSpan v1, VariantSpan v2); @Override...
### Question: PutOverlayMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_OVERLAY_MEDIA); dos.writeLong(to); dos.writeInt(hash); dos.writeInt(linkTypes.size()); f...
### Question: PutOverlayMediaOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; PutOverlayMediaOp other = (PutOverlayMediaOp) obj; if (hash != other.hash) return false; if (!linkTypes.equals(ot...
### Question: PutOverlayMediaOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + hash; result = prime * result + ((linkTypes == null) ? 0 : linkTypes.hashCode()); result = prime * result + (int) (to ^ (to >>> 32)); return result; } PutOverlayM...
### Question: StorageService { public <T> void delete(String id, Class<T> clazz) throws StorageException { if (Strings.isNullOrEmpty(id)) { throw new IllegalArgumentException("Id is null"); } if (clazz == null) { throw new IllegalArgumentException("Class is null"); } String key = id + "!" + clazz.getName(); Field[] fie...
### Question: DeleteVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.DELETE); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); } os.flush(); ret...
### Question: DeleteVariantOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; DeleteVariantOp other = (DeleteVariantOp) obj; if (!variantSpan.equals(other.variantSpan)) return false; return tru...
### Question: DeleteVariantOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + variantSpan.hashCode(); return result; } DeleteVariantOp(DataInputStream dis); DeleteVariantOp(VariantSpan variantSpan); @Override byte[] encode(); @Override boole...
### Question: CopyVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.COPY); dos.writeLong(to); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); } ...
### Question: CopyVariantOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CopyVariantOp other = (CopyVariantOp) obj; if (to != other.to) return false; if (!variantSpan.equals(other.variantSpa...
### Question: CopyVariantOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (int) (to ^ (to >>> 32)); result = prime * result + variantSpan.hashCode(); return result; } CopyVariantOp(DataInputStream dis); CopyVariantOp(long to, VariantSpan v...
### Question: MoveVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.MOVE); dos.writeLong(to); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); } ...
### Question: StorageService { public <T> Collection<T> getAll(Class<T> clazz) throws ClassNotFoundException, StorageException, IOException { List<T> c = new ArrayList<>(); Map<String, String> ids = new HashMap<>(); try (DBIterator it = db.iterator()) { it.seekToFirst(); String prevId = null; while (it.hasNext()) { Str...
### Question: MoveVariantOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; MoveVariantOp other = (MoveVariantOp) obj; if (to != other.to) return false; if (!variantSpan.equals(other.variantSpa...
### Question: MoveVariantOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (int) (to ^ (to >>> 32)); result = prime * result + variantSpan.hashCode(); return result; } MoveVariantOp(DataInputStream dis); MoveVariantOp(long to, VariantSpan v...
### Question: PutInvariantSpanOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_SPAN); dos.writeLong(to); dos.writeLong(invariantStart); dos.writeLong(width)...
### Question: PutInvariantSpanOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; PutInvariantSpanOp other = (PutInvariantSpanOp) obj; if (ripIndex != other.ripIndex) return false; if (invariant...
### Question: PutInvariantSpanOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ripIndex; result = prime * result + (int) (invariantStart ^ (invariantStart >>> 32)); result = prime * result + (int) (to ^ (to >>> 32)); result = prime * result...
### Question: PutInvariantMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.t...
### Question: PutInvariantMediaOp extends Op { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; PutInvariantMediaOp other = (PutInvariantMediaOp) obj; if (ripIndex != other.ripIndex) return false; if (to != ...
### Question: DocumentFile { public String getInvariantStream() { return invariantStream; } private DocumentFile(); static org.oulipo.streams.Compiler<DocumentFile> compiler(); static Decompiler<DocumentFile> decompiler(); Map<Integer, String> get(); String getDocumentHash(); String getEncyptedInvariantStream(); Strin...
### Question: PutInvariantMediaOp extends Op { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ripIndex; result = prime * result + (int) (to ^ (to >>> 32)); return result; } PutInvariantMediaOp(DataInputStream dis); PutInvariantMediaOp(long to, int ripIn...
### Question: PutOverlayOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_OVERLAY); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); dos.writeInt(li...
### Question: VariantSpan { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; VariantSpan other = (VariantSpan) obj; if (documentHash == null) { if (other.documentHash != null) return false; } else if (!documentHash...
### Question: InvariantSpan implements Invariant { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; InvariantSpan other = (InvariantSpan) obj; if (documentHash == null) { if (other.documentHash != null) return fals...
### Question: DocumentFile { public String getHashPreviousBlock() { return hashPreviousBlock; } private DocumentFile(); static org.oulipo.streams.Compiler<DocumentFile> compiler(); static Decompiler<DocumentFile> decompiler(); Map<Integer, String> get(); String getDocumentHash(); String getEncyptedInvariantStream(); S...
### Question: Node { public boolean isRoot() { return parent == null; } Node(long weight); Node(T value); long characterCount(); boolean isLeaf(); boolean isRightNode(); boolean isRoot(); Node<T> split(long leftPartitionWidth); @Override String toString(); public boolean isRed; public Node<T> left; public Node<T> pare...
### Question: FileInvariantStream implements InvariantStream { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = n...
### Question: ToggleOverlayOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.TOGGLE_OVERLAY); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); dos.write...
### Question: ApplyOverlayOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.APPLY_OVERLAY); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); dos.writeIn...
### Question: RopeVariantStream implements VariantStream<T> { @Override public void copy(long characterPosition, VariantSpan variantSpan) throws MalformedSpanException, IOException { putElements(characterPosition, getStreamElements(variantSpan)); } RopeVariantStream(String documentHash); RopeVariantStream(String docum...
### Question: RopeVariantStream implements VariantStream<T> { @Override public void delete(VariantSpan variantSpan) throws MalformedSpanException { if (variantSpan == null) { throw new MalformedSpanException("Variant span is null for delete operation"); } deleteRange(variantSpan); } RopeVariantStream(String documentHas...
### Question: RopeVariantStream implements VariantStream<T> { @Override public T index(long characterPosition) { if (root == null) { throw new IllegalStateException("Stream is empty"); } return RopeUtils.index(characterPosition, root, 0).node.value; } RopeVariantStream(String documentHash); RopeVariantStream(String do...
### Question: SlotKeySerDes { protected static Granularity granularityFromSlotKey(String s) { String field = s.split(",", -1)[0]; for (Granularity g : Granularity.granularities()) if (g.name().startsWith(field)) return g; return null; } static SlotKey deserialize(String stateStr); String serialize(SlotKey slotKey); St...
### Question: Emitter { public Emitter once(final String event, final Listener<T> fn) { Listener on = new Listener<T>() { @Override public void call(T... args) { Emitter.this.off(event, this); fn.call(args); } }; this.onceCallbacks.put(fn, on); this.on(event, on); return this; } Emitter on(String event, Listener fn); ...
### Question: Emitter { public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callba...
### Question: RollupEvent { public Locator getLocator() { return locator; } RollupEvent(Locator loc, Rollup rollup, String unit, String gran, long ts); Rollup getRollup(); Locator getLocator(); String getUnit(); String getGranularityName(); long getTimestamp(); void setUnit(String unit); }### Answer: @Test public void...
### Question: RollupEvent { public Rollup getRollup() { return rollup; } RollupEvent(Locator loc, Rollup rollup, String unit, String gran, long ts); Rollup getRollup(); Locator getLocator(); String getUnit(); String getGranularityName(); long getTimestamp(); void setUnit(String unit); }### Answer: @Test public void ro...