CharacterString.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Collections;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import java.util.List;
import Hoot.Runtime.Names.TypeName;
import Hoot.Runtime.Names.Primitive;
import Hoot.Runtime.Behaviors.Typified;
import Hoot.Runtime.Behaviors.HootRegistry;
import Hoot.Behaviors.Ordered;
import Hoot.Magnitudes.Integer;
import Hoot.Streams.TextReadStream;
import Smalltalk.Collections.*;
import Smalltalk.Magnitudes.Code;
import Smalltalk.Magnitudes.Scalar;
public abstract class CharacterString extends SequencedCollection implements Ordered, ReadableString
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends SequencedCollection.Metaclass implements Ordered.Metatype, ReadableString.Metatype
{
static final CharacterString.Metaclass $class = new CharacterString.Metaclass();
public Metaclass() {
this(CharacterString.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return CharacterString.class; }
}
/**
* @return
*/
public abstract java.lang.String primitiveString();
/**
* @return
*/
@Override public java.lang.String toString()
{
java.lang.String exitID = "CharacterString>>toString";
Frame f0 = new Frame(exitID);
return (java.lang.String)this.primitiveString();
}
/**
* @return
*/
public java.lang.String asPrimitive()
{
java.lang.String exitID = "CharacterString>>asPrimitive";
Frame f0 = new Frame(exitID);
return (java.lang.String)this.primitiveString();
}
/**
* @return
*/
@Override public Integer size()
{
java.lang.String exitID = "CharacterString>>size";
Frame f0 = new Frame(exitID);
return (Integer)SmallInteger.from(this.primitiveString().length());
}
/**
* @return
*/
public Typified resolvedToClass()
{
java.lang.String exitID = "CharacterString>>resolvedToClass";
Frame f0 = new Frame(exitID);
return (Typified)HootRegistry.getType(this.resolvedToPrimitiveClass());
}
/**
* @return
*/
public java.lang.Class resolvedToPrimitiveClass()
{
java.lang.String exitID = "CharacterString>>resolvedToPrimitiveClass";
Frame f0 = new Frame(exitID);
return (java.lang.Class)TypeName.fromName(this.primitiveString()).findPrimitiveClass();
}
/**
* @return
*/
@Override public int hashCode()
{
java.lang.String exitID = "CharacterString>>hashCode";
Frame f0 = new Frame(exitID);
return (int)this.primitiveString().hashCode();
}
/**
* @return
*/
@Override public Boolean equals(final Collected value)
{
java.lang.String exitID = "CharacterString>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(value).and(Predicate.with(f2 -> {
return this.equals(((CharacterString)value));
}, ""));
}
/**
* @return
*/
public Boolean equals(final CharacterString aString)
{
java.lang.String exitID = "CharacterString>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(this.primitiveString().equals(aString.primitiveString()));
}
/**
* @return
*/
public Boolean lessThan(final ReadableString upperBound)
{
java.lang.String exitID = "CharacterString>>lessThan";
Frame f0 = new Frame(exitID);
CharacterString boundary = ((CharacterString)upperBound);
int comparison = this.primitiveString().compareTo(boundary.primitiveString());
return (Boolean)(SmallInteger.from(comparison).lessThan(SmallInteger.from(0)));
}
/**
* @return
*/
public Boolean notMore(final ReadableString upperBound)
{
java.lang.String exitID = "CharacterString>>notMore";
Frame f0 = new Frame(exitID);
CharacterString boundary = ((CharacterString)upperBound);
int comparison = this.primitiveString().compareTo(boundary.primitiveString());
return (Boolean)(SmallInteger.from(comparison).notMore(SmallInteger.from(0)));
}
/**
* @return
*/
public Boolean moreThan(final ReadableString lowerBound)
{
java.lang.String exitID = "CharacterString>>moreThan";
Frame f0 = new Frame(exitID);
CharacterString boundary = ((CharacterString)lowerBound);
int comparison = this.primitiveString().compareTo(boundary.primitiveString());
return (Boolean)(SmallInteger.from(comparison).moreThan(SmallInteger.from(0)));
}
/**
* @return
*/
public Boolean notLess(final ReadableString lowerBound)
{
java.lang.String exitID = "CharacterString>>notLess";
Frame f0 = new Frame(exitID);
CharacterString boundary = ((CharacterString)lowerBound);
int comparison = this.primitiveString().compareTo(boundary.primitiveString());
return (Boolean)(SmallInteger.from(comparison).notLess(SmallInteger.from(0)));
}
/**
* @return
*/
public Boolean sameAs(final ReadableString candidate)
{
java.lang.String exitID = "CharacterString>>sameAs";
Frame f0 = new Frame(exitID);
CharacterString boundary = ((CharacterString)candidate);
int comparison = this.primitiveString().compareTo(boundary.primitiveString());
return (Boolean)(SmallInteger.from(comparison).equals(SmallInteger.from(0)));
}
/**
* @return
*/
@Override public Boolean between_and(final Scalar lowerBound, final Scalar upperBound)
{
java.lang.String exitID = "CharacterString>>between_and";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(lowerBound).and(Predicate.with(f2 -> {
return CharacterString.type().accepts(upperBound).and(Predicate.with(f3 -> {
return (this.notLess(((CharacterString)lowerBound))).and(Predicate.with(f4 -> {
return (this.notMore(((CharacterString)upperBound)));
}, ""));
}, ""));
}, ""));
}
/**
* @return
*/
@Override public Ordered max(final Scalar value)
{
java.lang.String exitID = "CharacterString>>max";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
CharacterString.type().accepts(value).ifFalse(Closure.with(f2 -> {
return (Ordered)f0.exit(exitID, this.max(value.printString()));
}, ""));
return (Ordered)f0.exit(exitID, (this.moreThan(((CharacterString)value))).ifTrue_ifFalse(Closure.with(f2 -> {
return this;
}, ""), Closure.with(f2 -> {
return value;
}, "")));
});
}
/**
* @return
*/
@Override public Ordered min(final Scalar value)
{
java.lang.String exitID = "CharacterString>>min";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
CharacterString.type().accepts(value).ifFalse(Closure.with(f2 -> {
return (Ordered)f0.exit(exitID, this.min(value.printString()));
}, ""));
return (Ordered)f0.exit(exitID, (this.lessThan(((CharacterString)value))).ifTrue_ifFalse(Closure.with(f2 -> {
return this;
}, ""), Closure.with(f2 -> {
return value;
}, "")));
});
}
/**
* @return
*/
@Override public Boolean lessThan(final Scalar upperBound)
{
java.lang.String exitID = "CharacterString>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(upperBound).and(Predicate.with(f2 -> {
return (this.lessThan(((CharacterString)upperBound)));
}, ""));
}
/**
* @return
*/
@Override public Boolean notMore(final Scalar upperBound)
{
java.lang.String exitID = "CharacterString>>notMore";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(upperBound).and(Predicate.with(f2 -> {
return (this.notMore(((CharacterString)upperBound)));
}, ""));
}
/**
* @return
*/
@Override public Boolean moreThan(final Scalar lowerBound)
{
java.lang.String exitID = "CharacterString>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(lowerBound).and(Predicate.with(f2 -> {
return (this.moreThan(((CharacterString)lowerBound)));
}, ""));
}
/**
* @return
*/
@Override public Boolean notLess(final Scalar lowerBound)
{
java.lang.String exitID = "CharacterString>>notLess";
Frame f0 = new Frame(exitID);
return (Boolean)CharacterString.type().accepts(lowerBound).and(Predicate.with(f2 -> {
return (this.notLess(((CharacterString)lowerBound)));
}, ""));
}
/**
* @return
*/
@Override public Boolean isString()
{
java.lang.String exitID = "CharacterString>>isString";
Frame f0 = new Frame(exitID);
return (Boolean)True.literal();
}
/**
* @return
*/
public Boolean sameAs(final String aString)
{
java.lang.String exitID = "CharacterString>>sameAs";
Frame f0 = new Frame(exitID);
return (Boolean)aString.sameAsString(this);
}
/**
* @return
*/
public Boolean sameAsString(final CharacterString aString)
{
java.lang.String exitID = "CharacterString>>sameAsString";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(this.primitiveString().equalsIgnoreCase(aString.primitiveString()));
}
/**
* @return
*/
@Override public Boolean includes(final Subject anObject)
{
java.lang.String exitID = "CharacterString>>includes";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
String.type().accepts(anObject).ifTrue(Closure.with(f2 -> {
return (Boolean)f0.exit(exitID, this.includes(((String)anObject)));
}, ""));
Character.type().accepts(anObject).ifTrue(Closure.with(f2 -> {
return (Boolean)f0.exit(exitID, this.includes(((Character)anObject)));
}, ""));
return (Boolean)f0.exit(exitID, False.literal());
});
}
/**
* @return
*/
public Boolean includes(final String s)
{
java.lang.String exitID = "CharacterString>>includes";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(this.primitiveString().contains(s.primitiveString()));
}
/**
* @return
*/
public Boolean includes(final Character c)
{
java.lang.String exitID = "CharacterString>>includes";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(this.primitiveString().contains(c.asString().primitiveString()));
}
/**
* @return
*/
@Override public String reverse()
{
java.lang.String exitID = "CharacterString>>reverse";
Frame f0 = new Frame(exitID);
return (String)String.from(Primitive.reverse(this.primitiveString()));
}
/**
* @return
*/
@Override public CharacterString append(final CollectedReadably aString)
{
java.lang.String exitID = "CharacterString>>append";
Frame f0 = new Frame(exitID);
return (CharacterString)(this.append(((CharacterString)aString)));
}
/**
* @return
*/
public CharacterString append(final CharacterString aString)
{
java.lang.String exitID = "CharacterString>>append";
Frame f0 = new Frame(exitID);
return (CharacterString)String.from((this.primitiveString() + aString.asPrimitive()));
}
/**
* @return
*/
public String asString()
{
java.lang.String exitID = "CharacterString>>asString";
Frame f0 = new Frame(exitID);
return (String)String.from(this.primitiveString());
}
/**
* @return
*/
public Symbol asSymbol()
{
java.lang.String exitID = "CharacterString>>asSymbol";
Frame f0 = new Frame(exitID);
return (Symbol)Symbol.from(this.primitiveString());
}
/**
* @return
*/
public Symbol asSelector()
{
java.lang.String exitID = "CharacterString>>asSelector";
Frame f0 = new Frame(exitID);
return (Symbol)this.asSymbol();
}
/**
* @return
*/
public CharacterString asLowercase()
{
java.lang.String exitID = "CharacterString>>asLowercase";
Frame f0 = new Frame(exitID);
return (CharacterString)String.from(this.primitiveString().toLowerCase());
}
/**
* @return
*/
public CharacterString asUppercase()
{
java.lang.String exitID = "CharacterString>>asUppercase";
Frame f0 = new Frame(exitID);
return (CharacterString)String.from(this.primitiveString().toUpperCase());
}
/**
* @return
*/
@Override public TextReadStream readStream()
{
java.lang.String exitID = "CharacterString>>readStream";
Frame f0 = new Frame(exitID);
return (TextReadStream)TextReadStream.type().with(this.asString());
}
/**
* @return
*/
public Boolean matches(final String aString)
{
java.lang.String exitID = "CharacterString>>matches";
Frame f0 = new Frame(exitID);
return (Boolean)new StringPattern(this).accepts(aString);
}
/**
* @return
*/
public List<String> subStrings()
{
java.lang.String exitID = "CharacterString>>subStrings";
Frame f0 = new Frame(exitID);
return (List<String>)this.subStrings(Character.type().space().asString());
}
/**
* @return
*/
public Array subStrings(final ReadableString separators)
{
java.lang.String exitID = "CharacterString>>subStrings";
Frame f0 = new Frame(exitID);
return (Array)new Array(this.subStrings(((String)separators)));
}
/**
* @return
*/
public List<String> subStrings(final String separators)
{
java.lang.String exitID = "CharacterString>>subStrings";
Frame f0 = new Frame(exitID);
return (List<String>)String.listWith(this.tokenized(separators));
}
/**
* @return
*/
protected List<java.lang.String> tokenized(final String separators)
{
java.lang.String exitID = "CharacterString>>tokenized";
Frame f0 = new Frame(exitID);
return (List<java.lang.String>)Primitive.tokenize(this.primitiveString(), separators.primitiveString());
}
/**
* @return
*/
public int length()
{
java.lang.String exitID = "CharacterString>>length";
Frame f0 = new Frame(exitID);
return (int)this.primitiveString().length();
}
/**
* @return
*/
public char charAt(final int index)
{
java.lang.String exitID = "CharacterString>>charAt";
Frame f0 = new Frame(exitID);
return (char)this.primitiveString().charAt(index);
}
/**
* @return
*/
public CharacterString subSequence(final int start, final int end)
{
java.lang.String exitID = "CharacterString>>subSequence";
Frame f0 = new Frame(exitID);
return (CharacterString)String.from(this.primitiveString().subSequence(start, end).toString());
}
}