ソースを参照

new: HashUtils.murmurHashIterable
fix: lambda tests
migration: remove assira1

Ranides Atterwim 4 年 前
コミット
50dccdb6e7
34 ファイル変更19 行追加4253 行削除
  1. 17 1
      assira.core/src/main/java/net/ranides/assira/generic/HashUtils.java
  2. 2 4
      assira.lambda/src/test/java/net/ranides/assira/reflection/LambdaReflectTest.java
  3. BIN
      assira1/doc/net.ranides.assira.collection.map.SwitchMapBenchmark.ods
  4. BIN
      assira1/doc/net.ranides.assira.text.StringsBenchmark.ods
  5. 0 215
      assira1/pom.xml
  6. 0 321
      assira1/src/main/java/net/ranides/assira/config/AbstractBranch.java
  7. 0 146
      assira1/src/main/java/net/ranides/assira/config/AbstractConfiguration.java
  8. 0 220
      assira1/src/main/java/net/ranides/assira/config/Branch.java
  9. 0 62
      assira1/src/main/java/net/ranides/assira/config/ConfigEvent.java
  10. 0 42
      assira1/src/main/java/net/ranides/assira/config/ConfigException.java
  11. 0 42
      assira1/src/main/java/net/ranides/assira/config/ConfigProvider.java
  12. 0 90
      assira1/src/main/java/net/ranides/assira/config/ConfigService.java
  13. 0 53
      assira1/src/main/java/net/ranides/assira/config/Configuration.java
  14. 0 69
      assira1/src/main/java/net/ranides/assira/config/JSONConfiguration.java
  15. 0 242
      assira1/src/main/java/net/ranides/assira/config/XMLConfiguration.java
  16. 0 304
      assira1/src/main/java/net/ranides/assira/text_format/AnsiAttr.java
  17. 0 93
      assira1/src/main/java/net/ranides/assira/text_format/AnsiBuilder.java
  18. 0 495
      assira1/src/main/java/net/ranides/assira/text_format/AnsiCharSequence.java
  19. 0 66
      assira1/src/main/java/net/ranides/assira/text_format/AnsiMatch.java
  20. 0 153
      assira1/src/main/java/net/ranides/assira/text_format/AnsiPattern.java
  21. 0 40
      assira1/src/main/java/net/ranides/assira/text_format/AnsiRegion.java
  22. 0 160
      assira1/src/main/java/net/ranides/assira/text_format/AnsiScheme.java
  23. 0 239
      assira1/src/main/java/net/ranides/assira/text_format/AnsiString.java
  24. 0 130
      assira1/src/main/java/net/ranides/assira/text_format/AnsiStrings.java
  25. 0 64
      assira1/src/test/java/net/ranides/assira/config/JSONConfigurationTest.java
  26. 0 47
      assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.java
  27. 0 110
      assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.json
  28. 0 134
      assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.xml
  29. 0 46
      assira1/src/test/java/net/ranides/assira/text/format/AnsiBuilderTest.java
  30. 0 71
      assira1/src/test/java/net/ranides/assira/text/format/AnsiGenerator.java
  31. 0 135
      assira1/src/test/java/net/ranides/assira/text/format/AnsiPatternTest.java
  32. 0 119
      assira1/src/test/java/net/ranides/assira/text/format/AnsiSchemeTest.java
  33. 0 268
      assira1/src/test/java/net/ranides/assira/text/format/AnsiStringTest.java
  34. 0 72
      assira1/src/test/java/net/ranides/assira/text/format/AnsiStringsTest.java

+ 17 - 1
assira.core/src/main/java/net/ranides/assira/generic/HashUtils.java

@@ -89,6 +89,14 @@ public final class HashUtils {
     public static int hashValues(int initial, int multiplier, Object... values) {
         return hashIterable(initial, multiplier, Arrays.asList(values));
     }
+
+    public static int murmurHashValues(Object... values) {
+        int hash =0;
+        for(Object v : values) {
+            hash ^= murmurHash3(hash(v));
+        }
+        return hash;
+    }
     
     public static int hashPair(Object value1, Object value2) {
         int a = value1 == null ? 0 : value1.hashCode();
@@ -118,7 +126,15 @@ public final class HashUtils {
         }
         return hash;
     }
-    
+
+    public static int murmurHashIterable(Iterable<?> values) {
+        int hash =0;
+        for(Object v : values) {
+            hash ^= murmurHash3(hash(v));
+        }
+        return hash;
+    }
+
     /**
      * Calculates hash value of text using SHA-512
      * @param value

+ 2 - 4
assira.lambda/src/test/java/net/ranides/assira/reflection/LambdaReflectTest.java

@@ -191,10 +191,8 @@ public class LambdaReflectTest {
         IMethod m1 = LambdaReflect.typeinfo(f1);
         IMethod m2 = LambdaReflect.typeinfo(f2);
 
-        MTFunction<Long> g1 = m1.handle(new TypeToken<>() {
-        });
-        MTFunction<Long> g2 = m2.handle(new TypeToken<>() {
-        });
+        MTFunction<Long> g1 = m1.handle(new TypeToken<MTFunction<Long>>() {});
+        MTFunction<Long> g2 = m2.handle(new TypeToken<MTFunction<Long>>() {});
 
         assertEquals(503, g1.calculate(500L, 1, 2));
         assertEquals(607, g2.calculate(600L, 3, 4));

BIN
assira1/doc/net.ranides.assira.collection.map.SwitchMapBenchmark.ods


BIN
assira1/doc/net.ranides.assira.text.StringsBenchmark.ods


+ 0 - 215
assira1/pom.xml

@@ -1,215 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" 
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>net.ranides</groupId>
-    <artifactId>assira</artifactId>
-    <version>0.81.0</version>
-    <packaging>jar</packaging>
-
-    <name>assira1</name>
-    <url>http://ranides.net/projects/assira</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <netbeans.hint.license>WTFPL</netbeans.hint.license>
-        <project.test.memory>512m</project.test.memory>
-        <project.argLine></project.argLine>
-    </properties>
-    
-    <distributionManagement>
-        <repository>
-            <id>maven.ranides.net</id>
-            <name>maven.ranides.net</name>
-            <url>ftp://maven.ranides.net/</url>
-        </repository>
-    </distributionManagement>
-    
-    <build>
-        <extensions>
-            <extension>
-                <groupId>org.apache.maven.wagon</groupId>
-                <artifactId>wagon-ftp</artifactId>
-                <version>1.0</version>
-            </extension>
-        </extensions>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.3.2</version>
-                <configuration>
-                    <source>1.7</source>
-                    <target>1.7</target>
-                    <compilerArgument>-Xlint:unchecked</compilerArgument>
-                    <compilerArgument>-proc:none</compilerArgument>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-pmd-plugin</artifactId>
-                <version>3.5</version>
-                <configuration>
-                    <rulesets>
-                        <ruleset>http://ranides.net/projects/pmd/3/assira.custom.xml</ruleset>
-                        <ruleset>http://ranides.net/projects/pmd/3/assira.standard.xml</ruleset>
-                        <!--
-                        <ruleset>http://dev.ranides.vnet/java/assira.custom.xml</ruleset>
-                        <ruleset>http://dev.ranides.vnet/java/assira.standard.xml</ruleset>
-                        -->
-                    </rulesets>
-                </configuration>
-            </plugin>
-            <!--
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>cobertura-maven-plugin</artifactId>
-                <version>2.5.2</version>
-            </plugin>
-            -->
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.7.5.201505241946</version>
-                <configuration>
-                    <propertyName>project.argLine</propertyName>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>report</id>
-                        <phase>prepare-package</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.9</version>
-                <executions>
-                    <execution>
-                        <id>javadocs-site</id>
-                        <phase>site</phase>
-                        <goals>
-                            <goal>javadoc</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <links>
-                        <link>http://download.oracle.com/javase/8/docs/api/</link>
-                    </links>
-                    <version>true</version>
-                    <show>public</show>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-source-plugin</artifactId>
-                <version>2.2.1</version>
-                <executions>
-                    <execution>
-                        <id>attach-sources</id>
-                        <goals>
-                            <goal>jar-no-fork</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.18.1</version>
-                <configuration>
-                    <argLine>@{project.argLine} -Xmx${project.test.memory}</argLine>
-                    <testFailureIgnore>false</testFailureIgnore>
-                    <skip>false</skip>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.9</version>
-            </plugin>
-        </plugins>
-    </reporting>
-
-    <repositories>
-        <repository>
-            <id>ranides.net</id>
-            <name>ranides.net</name>
-            <url>http://maven.ranides.net</url>
-        </repository>
-    </repositories>
-    
-    <dependencies>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>1.2.16</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-core</artifactId>
-            <version>2.0.1</version>
-            <type>jar</type>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.datatype</groupId>
-            <artifactId>jackson-datatype-json-org</artifactId>
-            <version>2.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>net.ranides</groupId>
-            <artifactId>caliper</artifactId>
-            <version>1.0L</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>net.ranides</groupId>
-            <artifactId>assira.asm</artifactId>
-            <version>5.0.4</version>
-        </dependency>
-        <dependency>
-            <groupId>eu.vitaliy</groupId>
-            <artifactId>mazovia-charset</artifactId>
-            <version>1.0</version>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>joda-time</groupId>
-            <artifactId>joda-time</artifactId>
-            <version>2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>net.ranides</groupId>
-            <artifactId>strom</artifactId>
-            <version>1.0</version>
-        </dependency>
-    </dependencies>
-</project>

+ 0 - 321
assira1/src/main/java/net/ranides/assira/config/AbstractBranch.java

@@ -1,321 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import net.ranides.assira.collection.SingleCollection;
-import net.ranides.assira.collection.list.ListAdapter;
-import net.ranides.assira.generic.TypeToken;
-import net.ranides.assira.text.LexicalCast;
-import net.ranides.assira.text.StringUtils;
-import net.ranides.assira.text.Strings;
-
-/**
- *
- * @author ranides
- */
-@SuppressWarnings({
-    "SIC_INNER_SHOULD_BE_STATIC_ANON"
-})
-public abstract class AbstractBranch implements Branch {
-
-    protected enum NoResult { CODE };
-
-
-    protected AbstractBranch() {
-        // do nothing
-    }
-
-    @Override
-    public Branch branch(String path) {
-        return new BasicBranch(path, get(path));
-    }
-
-    @Override
-    public List<Branch> branchList(String path) {
-        List<?> list = getList(path);
-        List<Branch> result = new ArrayList<>();
-        for(Object item : list) {
-            String home = path+"[" + result.size() + "]";
-            result.add(new BasicBranch(home, item));
-        }
-        return result;
-    }
-
-    @Override
-    public final Map<String,Object> asFlatMap() {
-        return flat(asMap(), "");
-    }
-
-    @Override
-    public final <T> T get(Class<T> type, String path, T ddefault) throws ConfigException {
-        return LexicalCast.cast(get(path, ddefault), type);
-    }
-
-    @Override
-    public final <T> T get(Class<T> type, String path) throws ConfigException {
-        return LexicalCast.cast(get(path), type);
-    }
-
-    @Override
-    public final <T> T get(TypeToken<T> type, String path, T ddefault) throws ConfigException {
-        return LexicalCast.cast(get(path, ddefault), type);
-    }
-
-    @Override
-    public final <T> T get(TypeToken<T> type, String path) throws ConfigException {
-        return LexicalCast.cast(get(path), type);
-    }
-
-    @Override
-    public final Object get(String path) throws ConfigException {
-        return get(path, NoResult.CODE);
-    }
-
-    @Override
-    public final List<?> getList(String path) throws ConfigException {
-        Object value = get(path, Collections.emptyList());
-        if(value instanceof List) {
-            return (List<?>)value;
-        } else {
-            return Arrays.asList(value);
-        }
-    }
-
-    @Override
-    public final <T> List<T> getList(Class<T> type, String path) {
-        Object value = get(path, Collections.emptyList());
-        if(value instanceof List) {
-            return new CastList<>(type, (List<?>)value);
-        } else {
-            return SingleCollection.of(LexicalCast.cast(value, type));
-        }
-    }
-
-    @Override
-    public final <T> List<T> getList(TypeToken<T> type, String path) {
-        Object value = get(path, Collections.emptyList());
-        if(value instanceof List) {
-            return new TokenCastList<>(type, (List<?>)value);
-        } else {
-            return SingleCollection.of(LexicalCast.cast(value, type));
-        }
-    }
-
-    @Override
-    public final <T> void put(Class<T> type, String path, Object value) throws ConfigException {
-        put(path, LexicalCast.cast(value, type));
-    }
-
-    @Override
-    public final <T> void put(TypeToken<T> type, String path, Object value) throws ConfigException {
-        put(path, LexicalCast.cast(value, type));
-    }
-
-    @Override
-    public final <T> void putList(Class<T> type, String path, List<?> value) throws ConfigException {
-        put(path, new CastList<>(type, value));
-    }
-
-    @Override
-    public final <T> void putList(TypeToken<T> type, String path, List<?> value) throws ConfigException {
-        put(path, new TokenCastList<>(type, value));
-    }
-
-    @Override
-    public final void putList(String path, List<?> value) throws ConfigException {
-        put(path, value);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void put(Object context, String path, Object value) throws ConfigException {
-        String[] keys   = path.split("\\.");
-
-        Object target = context;
-        for(int i=0, n=keys.length-1; i<n; i++) {
-            String key = keys[i];
-            if(target instanceof Map) {
-                Map<Object,Object> map = (Map)target;
-                if( !map.containsKey(key) ) {
-                    map.put(key, target = new HashMap<>());
-                } else {
-                    target = map.get(key);
-                }
-            } else {
-                throw new ConfigException("property not found: " + StringUtils.join(keys, "."));
-            }
-        }
-
-        if(target instanceof Map) {
-            Map<Object,Object> map = (Map)target;
-            map.put(keys[keys.length-1], value);
-        } else {
-            throw new ConfigException("can't change property: " + path);
-        }
-    }
-
-    protected Object get(Object context, String path, Object ddefault) throws ConfigException {
-        Object now = context;
-        for(String key : path.split("\\.") ) {
-            Matcher hit = Pattern.compile("(.*)\\[([0-9]+)\\]").matcher(key);
-            if(hit.find()) {
-                now = next(now, hit.group(1), Integer.parseInt(hit.group(2)));
-            } else {
-                now = next(now, key, -1);
-            }
-            if(now == AbstractConfiguration.NoResult.CODE) {
-                return reportNotFound(path, ddefault);
-            }
-        }
-        return now;
-    }
-
-    protected Object reportNotFound(String path, Object ddefault) {
-        if(NoResult.CODE == ddefault) { // NOPMD
-            throw new ConfigException("property not found: " + path);
-        } else {
-            return ddefault;
-        }
-    }
-
-    private Object next(Object context, String key, int index) {
-        if(!(context instanceof Map)) {
-            return AbstractConfiguration.NoResult.CODE;
-        }
-        final Map<?,?> now = (Map<?,?>)context;
-        if(!now.containsKey(key)) {
-            return AbstractConfiguration.NoResult.CODE;
-        }
-        Object value = now.get(key);
-        if(index == -1) {
-            return value;
-        }
-        if(value instanceof List) {
-            List<?> list = (List)value;
-            return index < list.size() ? list.get(index) : AbstractConfiguration.NoResult.CODE;
-        } else {
-            return (index == 0) ? value : AbstractConfiguration.NoResult.CODE;
-        }
-    }
-
-    protected Map<String,Object> flat(Object source, String seed) {
-        return flat(new LinkedHashMap<String, Object>(), source, seed);
-    }
-
-    private Map<String,Object> flat(Map<String,Object> target, Object source, String seed) {
-        if(source instanceof List) {
-            int index = 0;
-            for(Object item : (List<?>)source) {
-                flat(target, item, seed+"[" + index+ "]");
-                index++;
-            }
-            return target;
-        }
-
-        if(source instanceof Map) {
-            String key = Strings.isEmpty(seed) ? "" : seed + ".";
-            for (Map.Entry<?, ?> entry : ((Map<?,?>)source).entrySet()) {
-                flat(target, entry.getValue(), key + entry.getKey());
-            }
-            return target;
-        }
-
-        target.put(seed, source);
-        return target;
-    }
-
-    private static class CastList<T> extends ListAdapter<T, Object> {
-
-        private final Class<T> type;
-
-        @SuppressWarnings("unchecked")
-        public CastList(Class<T> type, List<?> content) {
-            super((List<Object>)content);
-            this.type = type;
-        }
-
-        @Override
-        public T apply(Object source) {
-            return LexicalCast.cast(source, type);
-        }
-
-    }
-
-    private static class TokenCastList<T> extends ListAdapter<T, Object> {
-
-        private final TypeToken<T> type;
-
-        @SuppressWarnings("unchecked")
-        public TokenCastList(TypeToken<T> type, List<?> content) {
-            super((List<Object>)content);
-            this.type = type;
-        }
-
-        @Override
-        public T apply(Object source) {
-            return LexicalCast.cast(source, type);
-        }
-
-    }
-
-    public class BasicBranch extends AbstractBranch {
-
-        private final String home;
-        private Object context;
-
-        public BasicBranch(String home, Object context) {
-            this.home = home;
-            initContext(context);
-        }
-
-        private void initContext(Object context) {
-            if(context == null) {
-                this.context = AbstractBranch.this.get(home);
-            } else {
-                this.context = context;
-            }
-            if( !(this.context instanceof Map) ) {
-                throw new ConfigException("path is not branch: " + home);
-            }
-        }
-
-        @Override
-        public Branch branch(String path) {
-            return AbstractBranch.this.branch(home + "." + path);
-        }
-
-        @Override
-        public List<Branch> branchList(String path) {
-            return AbstractBranch.this.branchList(home + "." + path);
-        }
-
-        @Override
-        public Map<String, Object> asMap() {
-            return flat(context, "");
-        }
-
-        @Override
-        public Object get(String path, Object ddefault) throws ConfigException {
-            return get(context, path, ddefault);
-        }
-
-        @Override
-        public void put(String path, Object value) throws ConfigException {
-            put(context, path, value);
-        }
-
-    }
-}

+ 0 - 146
assira1/src/main/java/net/ranides/assira/config/AbstractConfiguration.java

@@ -1,146 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import net.ranides.assira.events.Event;
-import net.ranides.assira.events.EventBinding;
-import net.ranides.assira.events.EventListener;
-import net.ranides.assira.events.EventRouter;
-import net.ranides.assira.events.EventDispatcher;
-
-/**
- *
- * @author ranides
- */
-@SuppressWarnings({
-    "SIC_INNER_SHOULD_BE_STATIC_ANON"
-})
-public abstract class AbstractConfiguration extends AbstractBranch implements Configuration {
-
-    protected final EventRouter dispatcher;
-
-    /**
-     * Pełna ścieżka podana podczas tworzenia konfiguracji
-     */
-    protected final String resource;
-    /**
-     * Rodzaj podanej ścieżki: "file" lub "url". W przypadku ścieżki nie określającej
-     * protokołu przyjmowany jest typ "file". W przypadku adresu URL konieczne jest
-     * podanie najpierw protokołu "url:" a następnie pełnego adresu, włącznie z
-     * konkretnym prefiksem określającym rodzaj transportu (np "http:", "ftp:", ...).
-     */
-    protected final String protocol;
-    /**
-     * Część pozostała po usunięciu rodzaju ze ścieżki rodzaju.
-     */
-    protected final String location;
-
-    /**
-     * Pamięć podręczna na przechowywane wartości konfiguracyjne.
-     */
-    protected Map<String, Object> values;
-
-    /**
-     * <p>
-     * Tworzy nową konfigurację powiązaną z zasobem wskazywanym przez ścieżkę.
-     * Konfiguracja może być ładowana i zapisywana z/do plików lokalnych.
-     * Może też być ładowana w trybie tylko-do-odczytu z zewnętrznego źródła
-     * określonego za pomocą URL.
-     * </p>
-     * <pre>
-     *   {@code
-     *   "/user/home/config.json"
-     *   "file:/user/home/config.json"
-     *   "file:d:/app/config.json"
-     *   "url:http://example.com/config.json"
-     * }</pre>
-     * @param path
-     */
-    public AbstractConfiguration(String path) {
-        this.dispatcher = new EventDispatcher();
-        this.values = new HashMap<>();
-        this.resource = path;
-
-        String[] params = path.split(":",2);
-        if(params.length == 2) {
-            protocol = (params.length == 2) ? params[0] : "file";
-            location = params[1];
-        } else {
-            protocol = "file";
-            location = params[0];
-        }
-    }
-
-    @Override
-    public String resource() {
-        return resource;
-    }
-
-    @Override
-    public Map<String,Object> asMap() {
-        return values;
-    }
-
-    @Override
-    public Object get(String path, Object ddefault) throws ConfigException {
-        return get(values, path, ddefault);
-    }
-
-    @Override
-    public void put(String path, Object value) throws ConfigException {
-        put(values, path, value);
-    }
-
-
-/* ************************************************************************** */
-
-
-    @Override
-    public <T extends Event> void addEventListener(Class<T> event, EventListener<? super T> listener) {
-        dispatcher.addEventListener(event, listener);
-    }
-
-    @Override
-    public <T extends Event> void removeEventListener(Class<T> event, EventListener<? super T> listener) {
-        dispatcher.removeEventListener(event, listener);
-    }
-
-    @Override
-    public void removeAllEventListeners() {
-        dispatcher.removeAllEventListeners();
-    }
-
-    @Override
-    public Collection<EventBinding<?>> getEventListeners() {
-        return dispatcher.getEventListeners();
-    }
-
-    @Override
-    public boolean signalEvent(Event event) {
-        return dispatcher.signalEvent(event);
-    }
-
-    @Override
-    public void dispose() {
-        dispatcher.dispose();
-    }
-
-    @Override
-    public void handleEvent(Event event) {
-        dispatcher.handleEvent(event);
-    }
-
-    @Override
-    public int getEventListenersCount() {
-        return dispatcher.getEventListenersCount();
-    }
-
-}

+ 0 - 220
assira1/src/main/java/net/ranides/assira/config/Branch.java

@@ -1,220 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import java.util.List;
-import java.util.Map;
-import net.ranides.assira.generic.TypeToken;
-
-/**
- * Interfejs reprezentujący zbiór wartości konfiguracyjnych, zorganizowanych w
- * strukturę drzewiastą. Gałąź może zawierać nie tylko konkretne wartości, ale
- * również kolejne, zagnieżdżone gałęzie.
- * @author ranides
- */
-public interface Branch {
-
-    /**
-     * <p>
-     * Zwraca mapę, która przechowuje wartości konfiguracyjne. Format mapy nie
-     * jest określony - w szczególności obiekty zagnieżdżone mogą być
-     * reprezentowane jako zagnieżdżone mapy, albo być spłaszczone. 1-elementowe
-     * listy obiektów mogą być kolekacji albo po prostu elementami bezpośrednio
-     * wstawionymi do mapy. Modyfikacja mapy jest niezdefiniowana: może wpływać
-     * na konfigurację, ale nie musi.
-     * </p><p>
-     * Z powyższych powodów metoda zalecana tylko podczas pracy z konkretną
-     * implementacją.
-     * </p>
-     * @return
-     */
-    Map<String,Object> asMap();
-
-    /**
-     * Zwraca spłaszczoną mapę, zawierającą wszystkie ustawienia w postaci:
-     * "ścieżka - wartość". Modyfikacja mapy nie wpływa na wartość konfiguracji.
-     * Ale jeśli wartości zapisane w konfiguracji nie są obiektami typu
-     * <i>immutable</i> to ich modyfikacja jest niezdefiniowana.
-     * @return
-     */
-    Map<String,Object> asFlatMap();
-
-    /**
-     * Zwraca gałąź zagnieżdżoną w bieżącym obiekcie.
-     * @param path
-     * @return
-     */
-    Branch branch(String path);
-
-    /**
-     * Zwraca listę ścieżek, reprezentujących gałęzie zawarte w bieżącym obiekcie.
-     * @param path
-     * @return
-     */
-    List<Branch> branchList(String path);
-
-/* ************************************************************************** */
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji dokonując w razie potrzeby
-     * rzutowania za pomocą {@link net.ranides.assira.text.LexicalCast#cast}. Zwraca wartość domyślną, jeśli
-     * wartość nie istnieje.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param ddefault
-     * @return
-     */
-<T> T get(TypeToken<T> type, String path, T ddefault);
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji dokonując w razie potrzeby
-     * rzutowania za pomocą {@link LexicalCast#cast}. Rzuca wyjątkiem, jeśli wartość
-     * nie istnieje.
-     * @param <T>
-     * @param type
-     * @param path
-     * @return
-     * @throws ConfigException
-     */
-    <T> T get(TypeToken<T> type, String path) throws ConfigException;
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji dokonując w razie potrzeby
-     * rzutowania za pomocą {@link LexicalCast#cast}. Zwraca wartość domyślną, jeśli
-     * wartość nie istnieje.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param ddefault
-     * @return
-     */
-    <T> T get(Class<T> type, String path, T ddefault);
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji dokonując w razie potrzeby
-     * rzutowania za pomocą {@link LexicalCast#cast}. Rzuca wyjątkiem, jeśli wartość
-     * nie istnieje.
-     * @param <T>
-     * @param type
-     * @param path
-     * @return
-     * @throws ConfigException
-     */
-    <T> T get(Class<T> type, String path) throws ConfigException;
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji
-     * @param path
-     * @param ddefault
-     * @return odczytana wartość, lub ddefault, jeśli nie znaleziono w konfiguracji
-     * @throws ConfigException
-     */
-    Object get(String path, Object ddefault) throws ConfigException;
-
-    /**
-     * Pobiera wartość zapisaną we wskazanej lokalizacji
-     * @param path
-     * @return odczytana wartość
-     * @throws ConfigException jeśli nie znaleziono w konfiguracji
-     */
-    Object get(String path) throws ConfigException;
-
-    /**
-     * Pobiera listę wartości zapisanych we wskazanej lokalizacji. Może zwrócić
-     * pustą listę, jeśli nie znaleziono niczego we wskazanej lokalizacji. W razie
-     * potrzeby dokonuje odpowiedniego rzutowania elementów listy za pomocą
-     * {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @return
-     */
-    <T> List<T> getList(TypeToken<T> type, String path);
-
-    /**
-     * Pobiera listę wartości zapisanych we wskazanej lokalizacji. Może zwrócić
-     * pustą listę, jeśli nie znaleziono niczego we wskazanej lokalizacji. W razie
-     * potrzeby dokonuje odpowiedniego rzutowania elementów listy za pomocą
-     * {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @return
-     */
-    <T> List<T> getList(Class<T> type, String path);
-
-    /**
-     * Pobiera listę wartości zapisanych we wskazanej lokalizacji
-     * @param path
-     * @return pusta lista, jeśli nie znaleziono w konfiguracji
-     * @throws ConfigException
-     */
-    List<?> getList(String path) throws ConfigException;
-
-    /**
-     * Zmienia wartość pod wskazaną lokalizacją. W razie potrzeby dokonuje rzutowania
-     * {@code value} na typ {@type} za pomocą {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    <T> void put(TypeToken<T> type, String path, Object value) throws ConfigException;
-
-    /**
-     * Zmienia wartość pod wskazaną lokalizacją. W razie potrzeby dokonuje rzutowania
-     * {@code value} na typ {@type} za pomocą {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    <T> void put(Class<T> type, String path, Object value) throws ConfigException;
-
-    /**
-     * Zmienia wartość pod wskazaną lokalizacją
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    void put(String path, Object value) throws ConfigException;
-
-    /**
-     * Wstawia wiele wartości pod wskazaną lokalizację (usuwając poprzednie).
-     * W razie potrzeby dokonuje rzutowania elementów listy na typ {@type} za pomocą
-     * {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    <T> void putList(TypeToken<T> type, String path, List<?> value) throws ConfigException;
-
-    /**
-     * Umieszcza listę wartości pod wskazaną lokalizacją.
-     * W razie potrzeby dokonuje rzutowania elementów listy na typ {@type} za pomocą
-     * {@link LexicalCast#cast}.
-     * @param <T>
-     * @param type
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    <T> void putList(Class<T> type, String path, List<?> value) throws ConfigException;
-
-    /**
-     * Umieszcza listę wartości pod wskazaną lokalizacją
-     * @param path
-     * @param value
-     * @throws ConfigException
-     */
-    void putList(String path, List<?> value) throws ConfigException;
-}

+ 0 - 62
assira1/src/main/java/net/ranides/assira/config/ConfigEvent.java

@@ -1,62 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import net.ranides.assira.events.Event;
-
-/**
- *
- * @author ranides
- */
-public abstract class ConfigEvent implements Event {
-
-    private final Configuration source;
-
-    protected ConfigEvent(Configuration source) {
-        this.source = source;
-    }
-
-    public static Change change(Configuration source, String branch) {
-        return new Change(source, branch);
-    }
-
-    public static Save save(Configuration source) {
-        return new Save(source);
-    }
-
-    public static Load load(Configuration source) {
-        return new Load(source);
-    }
-
-    public Configuration source() {
-        return source;
-    }
-
-    public static class Change extends ConfigEvent {
-
-        private final String branch;
-
-        protected Change(Configuration source, String branch) {
-            super(source);
-            this.branch = branch;
-        }
-
-        public String branch() {
-            return branch;
-        }
-
-    }
-
-    public static class Save extends ConfigEvent {
-        protected Save(Configuration source) { super(source); }
-    }
-
-    public static class Load extends ConfigEvent {
-        protected Load(Configuration source) { super(source); }
-    }
-
-}

+ 0 - 42
assira1/src/main/java/net/ranides/assira/config/ConfigException.java

@@ -1,42 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-/**
- * Wyjątek "unchecked" rzucany przez klasy do obsługi konfiguracji
- * @see Configuration
- * @author ranides
- */
-public class ConfigException extends RuntimeException {
-
-    /**
-     * Tworzy wyjątek z podanym komunikatem
-     * @param message 
-     */
-    public ConfigException(String message) {
-        super(message);
-    }
-
-    /**
-     * Tworzy wyjątek z podaną przyczyną błędu.
-     * @param cause 
-     */
-    public ConfigException(Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Tworzy wyjątek z podanym komunikatem oraz przyczyną błędu.
-     * @param message 
-     * @param cause 
-     */
-    public ConfigException(String message, Throwable cause) {
-        super(message, cause);
-    }
-    
-}

+ 0 - 42
assira1/src/main/java/net/ranides/assira/config/ConfigProvider.java

@@ -1,42 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-import java.util.Collection;
-
-/**
- * Fabryka konfiguracji - interfejs używany przez {@link ConfigService}.
- * @see ConfigManager
- * @author ranides
- */
-public interface ConfigProvider {
-    
-    /**
-     * Nazwa fabryki.
-     * @return
-     */
-    String getName();
-    
-    /**
-     * Tworzy nową instancję obiektu konfiguracyjnego powiązanego z podaną ścieżką. 
-     * Zwrócona konfiguracja nie musi być w stanie załadowanym. Kilkukrotne wywołanie
-     * metody z tym samym argumentem zwraca różne obiekty. Argument {@code path}
-     * nie powinien zawierać prefiksu z nazwą providera.
-     * @param path
-     * @return
-     */
-    Configuration getInstance(String path);
-    
-    /**
-     * Zwraca listę wszystkich dostępnych ścieżek, dla których fabryka może utworzyć
-     * konfigurację. Metoda opcjonalna.
-     * @return
-     */
-    Collection<String> list();
-    
-}

+ 0 - 90
assira1/src/main/java/net/ranides/assira/config/ConfigService.java

@@ -1,90 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-import java.util.Map;
-import java.util.ServiceLoader;
-import net.ranides.assira.collection.map.Cache;
-
-/**
- * Klasa zarządzająca cyklem wyszukiwania, ładowania i dostępem do poszczególnych
- * konfiguracji. Dzięki menagerowi nie musimy w aplikacji tworzyć globalnie
- * dostępnych instancji - każdy moduł może zażądać udostępnienia odpowiedniej
- * konfiguracji na podstawie typu oraz abstrakcyjnej nazwy.
- *
- * <p>
- * Klasa zarządza również zarejestrowanymi fabrykami, obsługującymi różne formaty
- * konfiguracyjne.
- * </p>
- * @author ranides
- */
-public final class ConfigService {
-
-    private ConfigService() { /* utility class */ }
-
-    private static final Cache<String, ConfigProvider> FACTORIES = new Cache<>();
-
-    private static final Map<String, Configuration> CONFIGS = new Cache<>(Integer.MAX_VALUE, 8);
-
-    /**
-     * <p>
-     * Zwraca konfigurację o podanej nazwie oraz typie.
-     * Zwrócona konfiguracja jest załadowana. Jeśli wskazana konfiguracja została już
-     * załadowana do pamięci wcześnej, operacja nie jest powtarzana. Metoda może być
-     * wywoływana wielokrotnie bez negatywnego wpływu na wydajność.
-     * </p><p>
-     * Uwaga! Wielokrotne wywołanie metody gwarantuje, że zwróci poprzednią
-     * instancję tak długo, jak gdziekolwiek w programie będzie istnieć referencja
-     * do niej. Z tego względu każda niezależna część aplikacji, która chce mieć
-     * gwarancję, że wprowadzane przez nią zmiany będą globalnie widoczne, musi
-     * przechowywać referencję do wyniku. Innymi słowy, z {@link Configuration} należy
-     * postępować identycznie jak z {@link java.util.logging.Logger}.
-     * </p>
-     * @param path "provider:path" co najczęściej przekłada się na "provider:protocol:location"
-     * @return
-     */
-    public static Configuration getInstance(String path) {
-        if( CONFIGS.containsKey(path) ) {
-            return CONFIGS.get(path);
-        }
-        String[] params = path.split(":", 2);
-        if(params.length != 2) {
-            throw new IllegalArgumentException("Illegal name of configuration: " + path);
-        }
-        Configuration result = getProvider(params[0]).getInstance(params[1]);
-        CONFIGS.put(path, result);
-        return result.load();
-    }
-
-    /**
-     * Zwraca fabrykę o określonej nazwie. Wyniki zwracane przez metodę są buforowane,
-     * ale nie jest gwarantowane, że wywołanie metody z tą samą nazwą zwraci te
-     * same obiekty. Jeśli aplikacja musi cały czas pracować z tym samym providerem,
-     * to musi samodzielnie przechowywać referencję do wyniku uzyskanego po pierwszym
-     * wywołaniu.
-     * @param name
-     * @return
-     */
-    public static ConfigProvider getProvider(String name) {
-        if( FACTORIES.containsKey(name) ) {
-            return FACTORIES.get(name);
-        }
-        for(ConfigProvider item : ServiceLoader.load(ConfigProvider.class) ) {
-            if( name.equals(item.getName()) ) {
-                FACTORIES.put(name, item);
-                return item;
-            }
-        }
-        throw new ConfigException("ConfigFactory not found: " + name);
-    }
-
-    public static void register(ConfigProvider provider) {
-        FACTORIES.put(provider.getName(), provider);
-    }
-
-}

+ 0 - 53
assira1/src/main/java/net/ranides/assira/config/Configuration.java

@@ -1,53 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.config;
-
-import net.ranides.assira.events.EventRouter;
-
-/**
- * <p>
- * Interfejs reprezentujący konfigurację, którą można nie tylko czytać i modyfikować,
- * ale również obserwować zmiany (obsługuje klasyczny model zdarzeń assira).
- * </p><p>
- * Każda klasa implementująca interfejs powinna udostępniać konstruktor pobierający
- * nazwę konfiguracji i opcjonalnie dokonywać w nim pierwszego ładowania danych.
- * Metody load i save są opcjonalne i wywoływane przez użytkownika w celu odświeżenia/ sychronizacji
- * danych z fizycznym nośnikiem.
- * </p><p>
- * Uwaga! Wielokrotne utworzenie konfiguracji za pomocą {@link ConfigService} zwróci
- * poprzednią instancję tak długo, jak gdziekolwiek w programie będzie istnieć referencja
- * do niej. Z tego względu każda niezależna część aplikacji, która chce mieć
- * gwarancję, że wprowadzane przez nią zmiany będą globalnie widoczne, musi
- * przechowywać referencję do wyniku. Innymi słowy, z {@link Configuration} należy
- * postępować identycznie jak z {@link java.util.logging.Logger}.
- * </p>
- * @author ranides
- */
-public interface Configuration extends Branch, EventRouter {
-
-    /**
-     * Abstrakcyjna ścieżka do załadowanej konfiguracji
-     * @return
-     */
-    String resource();
-
-    /**
-     * Ładuje konfigurację z persistent storage
-     * @return
-     * @throws ConfigException
-     */
-    Configuration load() throws ConfigException;
-
-    /**
-     * Zapisuje konfigurację do persistent storage
-     * @return
-     * @throws ConfigException
-     */
-    Configuration save() throws ConfigException;
-
-}

+ 0 - 69
assira1/src/main/java/net/ranides/assira/config/JSONConfiguration.java

@@ -1,69 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
-
-/**
- * Klasa obsługująca dostęp do plików z konfiguracją w formacie JSON. 
- * @author ranides
- */
-public class JSONConfiguration extends AbstractConfiguration {
-    
-    private static final ObjectMapper mapper;
-        
-    static {
-        mapper = new ObjectMapper();
-        mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
-    }
-
-    /**
-     * Tworzy nową konfigurację powiązaną z zasobem wskazywanym przez ścieżkę.
-     * Wskazany zasób musi prowadzić do treści w formacie JSON.
-     * @param path
-     */
-    public JSONConfiguration(String path) {
-        super(path);
-    }
-
-    @Override
-    public Configuration load() throws ConfigException {
-        try {
-            if("file".equals(protocol)) {
-                values = mapper.readValue(new File(location), new TypeReference<Map<String,Object>>(){});
-                return this;
-            }
-            if("url".equals(protocol)) {
-                values = mapper.readValue(new URL(location), new TypeReference<Map<String,Object>>(){});
-                return this;
-            }
-        } catch(IOException cause) {
-            throw new ConfigException(cause);
-        }
-        return this;
-    }
-
-    @Override
-    public Configuration save() throws ConfigException {
-        try {
-            if("file".equals(protocol)) {
-                mapper.writeValue(new File(location), values);
-                return this;
-            }
-        } catch(IOException cause) {
-            throw new ConfigException(cause);
-        }
-        throw new ConfigException("You can save configuration to files only.");
-    }
-    
-}

+ 0 - 242
assira1/src/main/java/net/ranides/assira/config/XMLConfiguration.java

@@ -1,242 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.xml.transform.TransformerException;
-import net.ranides.assira.collection.ArrayUtils;
-import net.ranides.assira.generic.ValueUtils;
-import net.ranides.assira.text.LexicalCast;
-import net.ranides.assira.text.StringUtils;
-import net.ranides.assira.xml.NodeCollection;
-import net.ranides.assira.xml.NodeType;
-import net.ranides.assira.xml.XMLTransform;
-import org.w3c.dom.Node;
-
-/**
- * Klasa obsługująca dostęp do plików z konfiguracją w formacie JSON.
- * @author ranides
- */
-public class XMLConfiguration extends AbstractConfiguration {
-
-    private static final FPath ROOT_FPATH = new FPath();
-
-    /**
-     * Tworzy nową konfigurację powiązaną z zasobem wskazywanym przez ścieżkę.
-     * Wskazany zasób musi prowadzić do treści w formacie JSON.
-     * @param path
-     */
-    public XMLConfiguration(String path) {
-        super(path);
-    }
-
-    @Override
-    public Configuration load() throws ConfigException {
-        try {
-            if("file".equals(protocol)) {
-                values = new LinkedHashMap<>();
-                putNode(values, XMLTransform.parse(new File(location)), ROOT_FPATH, 0);
-                return this;
-            }
-            if("url".equals(protocol)) {
-                values = new LinkedHashMap<>();
-                putNode(values, XMLTransform.parse(new URL(location)), ROOT_FPATH, 0);
-                return this;
-            }
-        } catch(IOException cause) {
-            throw new ConfigException(cause);
-        } catch(TransformerException cause) {
-            throw new ConfigException(cause);
-        }
-        return this;
-    }
-
-    @Override
-    public Configuration save() throws ConfigException {
-        try {
-            if("file".equals(protocol)) {
-                // XMLTransform.source(new File(location), null);
-                // return this;
-                // fix (prev # 8) XMLConfiguration.save
-                throw new IOException("N/A");
-            }
-        } catch(IOException cause) {
-            throw new ConfigException(cause);
-        }
-        throw new ConfigException("You can save configuration to files only.");
-    }
-
-    static void putNode(Map<String, Object> target, Node node, FPath path, int index) {
-        NodeType type = NodeType.valueOf(node);
-
-        FPath prefix;
-        if(type == NodeType.DOCUMENT) {
-            prefix = path;
-        } else {
-            prefix = new FPath(path, node.getNodeName(), index);
-        }
-
-        int count = 0;
-        String prev = null;
-
-        for(Node item : NodeCollection.nodes(node)) {
-            if(ValueUtils.equals(item.getNodeName(), prev)) {
-                count++;
-            }
-            if(NodeType.ELEMENT.match(item)) {
-                prev = item.getNodeName();
-                putNode(target, item, prefix, count);
-                continue;
-            }
-            if(NodeType.TEXT.match(item)) {
-                String text = StringUtils.trim(item.getTextContent());
-                if(!text.isEmpty()) {
-                    putValue(target, prefix, text);
-                }
-                continue;
-            }
-        }
-
-    }
-
-    @SuppressWarnings("unchecked")
-    static void putValue(Map<String, Object> target, FPath path, String value) {
-        Map<String, Object> now = target;
-        for(FItem item : path) {
-            // wstawiamy pierwszy element, jeśli coś już siedzi, to jest to map
-            if( item.index==0 ) {
-                Object prev = now.get(item.name);
-                if(prev instanceof Map) {
-                    now = (Map)prev;
-                } else {
-                    now = indent(now, item.name);
-                }
-            }
-            // wstawiamy drugi element, transformacja na listę...
-            else if( item.index==1 ) {
-                Object prev = now.get(item.name);
-                if(prev instanceof List) {
-                    now = (Map)(((List)prev).get(item.index));
-                } else {
-                    now = pair(now, item.name);
-                }
-            // wstawiamy kolejne elementy, lista musi już siedzieć
-            } else {
-                List<Object> prev = (List<Object>)now.get(item.name);
-                if( item.index < prev.size() ) {
-                    now = (Map)prev.get(item.index);
-                } else {
-                    now = indent(prev);
-                }
-            }
-        }
-
-        FItem head = path.head();
-        // wstawiamy pierwszy element, nic nie powinno siedzieć...
-        if(head.index == 0) {
-            now.put(head.name, value);
-        }
-        // wstawiamy drugi element, "coś" powinno siedzieć
-        else if(head.index == 1) {
-            pair(now, head.name, value);
-        }
-        // wstawiamy kolejne elementy, lista musi już siedzieć
-        else {
-            ((List<Object>)now.get(head.name)).add(value);
-        }
-    }
-
-    private static Map<String, Object> indent(Map<String, Object> target, String name) {
-        Map<String, Object> map = new LinkedHashMap<>();
-        target.put(name, map);
-        return map;
-    }
-
-    private static Map<String, Object> indent(List<Object> target) {
-        Map<String, Object> map = new LinkedHashMap<>();
-        target.add(map);
-        return map;
-    }
-
-    private static Map<String, Object> pair(Map<String, Object> target, String name) {
-        return pair(target, name, new LinkedHashMap<String, Object>());
-    }
-
-    @SuppressWarnings("PMD.UnusedPrivateMethod") // false positive
-    private static <T> T pair(Map<String, Object> target, String name, T value) {
-        List<Object> nlist = new LinkedList<>();
-        nlist.add( target.get(name));
-        nlist.add( value );
-        target.put(name, nlist);
-        return value;
-    }
-
-    static final class FItem {
-        final String name;
-        final int index;
-
-        public FItem(String name, int index) {
-            this.name = name;
-            this.index = index;
-        }
-
-        @Override
-        public String toString() {
-            return name + '[' + index + ']';
-        }
-
-    }
-
-    static final class FPath implements Iterable<FItem> {
-
-        FItem[] items;
-
-        public FPath() {
-            this.items = new FItem[0];
-        }
-
-        public FPath(String name, int index) {
-            this(ROOT_FPATH, name, index);
-        }
-
-        public FPath(FPath root, String name, int index) {
-            this(root, name.split("\\."), index);
-        }
-
-        FPath(FPath root, String[] names, int index) {
-            int n = names.length;
-            int offset = root.items.length;
-            this.items = Arrays.copyOf(root.items, offset+n);
-            for(int i=0; i<n; i++) {
-                this.items[offset+i] = new FItem(names[i], index);
-            }
-        }
-
-        @Override
-        public String toString() {
-            return StringUtils.join(LexicalCast.asList(items), " / ");
-        }
-
-        @Override
-        public Iterator<FItem> iterator() {
-            return ArrayUtils.iterator(items, items.length-1, 0);
-        }
-
-        public FItem head() {
-            return items.length>0 ? items[items.length-1] : null;
-        }
-
-    }
-}

+ 0 - 304
assira1/src/main/java/net/ranides/assira/text_format/AnsiAttr.java

@@ -1,304 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.io.Serializable;
-import net.ranides.assira.math.Bitwise;
-import net.ranides.assira.math.HashHelper;
-
-/**
- *
- * @author ranides
- */
-public abstract class AnsiAttr implements Serializable {
-    
-    private static final long serialVersionUID = 3L;
-    
-    public static final AnsiAttr DEFAULT = new Value(0, 0, 0, 0);
-    
-    public static final int NORMAL          = 0x0000;
-    
-    public static final int BOLD            = 0x0001;
-    
-    public static final int UNDERLINE       = 0x0002;
-    
-    public static final int INVERT          = 0x0004;
-    
-    public static final int SYMBOL          = 0x0008;
-    
-    public static final int NARROW          = 0x0010;
-    
-    public static final int STRIKE          = 0x0020;
-    
-    public static final int FRESH           = 0x0040;
-    
-    public static final int CHANGED         = 0x0080;
-    
-    public static final int NO_BOLD         = 0x0100;
-    
-    public static final int NO_UNDERLINE    = 0x0200;
-    
-    public static final int NO_INVERT       = 0x0400;
-    
-    public static final int NO_SYMBOL       = 0x0800;
-    
-    public static final int NO_NARROW       = 0x1000;
-    
-    public static final int NO_STRIKE       = 0x2000;
-    
-    public static final int NO_FRESH        = 0x4000;
-    
-    public static final int NO_CHANGED      = 0x8000;
-    
-    
-    public static final int MASK_FLAGS_SET  = 0x00FF;
-    
-    public static final int MASK_FLAGS_CLR  = 0xFF00;
-    
-    
-    public static final int CMP_FORE        = 0x010000;
-    
-    public static final int CMP_BACK        = 0x020000;
-    
-    public static final int CMP_FLAGS       = 0x040000;
-    
-    public static final int CMP_FONT        = 0x080000;
-    
-    public static final int CMP_CHAR        = 0x100000;
-    
-    public static final int CMP_FLAGS_ALL   = CMP_FLAGS | MASK_FLAGS_SET;
-    
-    public static final int CMP_FLAGS_PUBLIC= CMP_FLAGS | 0x003F;
-    
-    public static final int CMP_PUBLIC      = CMP_CHAR | CMP_FORE | CMP_BACK | CMP_FONT | CMP_FLAGS_PUBLIC;
-    
-    public static final int CMP_ALL         = CMP_PUBLIC | CMP_FLAGS_ALL;
-    
-    public static final int CMP_IDENTICAL   = 0xFFFFFFFF;    
-
-    
-    @Override
-    public final boolean equals(Object object) {
-        if(!(object instanceof AnsiAttr)) {
-            return false;
-        }
-        return equals((AnsiAttr)object, AnsiAttr.CMP_PUBLIC);
-    }
-    
-    public final boolean equals(AnsiAttr value, int flags) {
-        if(this == value) {
-            return true;
-        }
-        if (Bitwise.has(flags, AnsiAttr.CMP_FORE) && getFore() != value.getFore()) {
-            return false;
-        }
-        if (Bitwise.has(flags, AnsiAttr.CMP_BACK) && getBack() != value.getBack()) {
-            return false;
-        }
-        if (Bitwise.has(flags, AnsiAttr.CMP_FONT) && getFont() != value.getFont()) {
-            return false;
-        }
-        if ((getFlags() & flags) != (value.getFlags() & flags)) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public final int hashCode() {
-        return HashHelper.hashValues(7, 19, getFore(), getBack(), getFlags() & AnsiAttr.CMP_PUBLIC);
-    }
-    
-    @Override
-    public final String toString() {
-        return String.format("AnsiAttr{%d %d %d %s}", getBack(), getFore(), getFont(), AnsiStrings.encodeFlags(getFlags()));
-    }
-    
-    /**
-     * Zwraca przypisany numer koloru tekstu. Numer może być zamieniony na
-     * graficzną reprezentację za pomocą {@link AnsiColorScheme}.
-     * @see #getComputedFore() 
-     * @return
-     */
-    public abstract int getFore();
-    
-    /**
-     * Zwraca przypisany numer koloru tła. Numer może być zamieniony na
-     * graficzną reprezentację za pomocą {@link AnsiColorScheme}. 
-     * @see #getComputedBack() 
-     * @return
-     */
-    public abstract int getBack();
-    
-    /**
-     * Zwraca przypisane atrybuty tekstu.
-     * @return
-     */
-    public abstract int getFlags();
-    
-    /**
-     * Zwraca przypisany numer czcionki. Numer może być zamieniony na
-     * graficzną reprezentację za pomocą {@link AnsiFontScheme}.
-     * @see #getComputedFont()
-     * @return
-     */
-    public abstract int getFont();
-    
-    /**
-     * Metoda opcjonalna: zwraca przypisany kolor tekstu. Ogólnie metoda zwraca rozsądny
-     * wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów
-     * ({@link AnsiColorScheme}.
-     * @return
-     */
-    public abstract Color getComputedFore();
-    
-    /**
-     * Metoda opcjonalna: zwraca przypisany kolor tła. Ogólnie metoda zwraca rozsądny
-     * wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów
-     * ({@link AnsiColorScheme}.
-     * @return
-     */
-    public abstract Color getComputedBack();
-
-    /**
-     * Metoda opcjonalna: zwraca przypisaną czcionkę. Ogólnie metoda zwraca rozsądny
-     * wynik, jeśli obiekt został powiązany z odpowiednim schematem czcionek
-     * ({@link AnsiFontScheme}.
-     * @return
-     */
-    public abstract Font getComputedFont();
-    
-    public final boolean isDefault() {
-        return 
-            0 == getBack() &&
-            0 == getFore() &&
-            0== getFont() &&
-            AnsiAttr.NORMAL == getFlags();
-    }
-    
-    public final boolean isComputedDefault() {
-        return 
-            null == getComputedBack() &&
-            null == getComputedFore() &&
-            null == getComputedFont() &&
-            AnsiAttr.NORMAL == getFlags();
-    }
-    
-    public static class Value extends AnsiAttr {
-        
-        private static final long serialVersionUID = 1L;
-        
-        protected final int back;
-        protected final int fore;
-        protected final int font;
-        protected final int flags;
-        
-        public Value(int back, int fore, int font, int flags) {
-            this.back = back;
-            this.fore = fore;
-            this.font = font;
-            this.flags = flags;
-        }
-
-        @Override
-        public final int getFore() {
-            return fore;
-        }
-
-        @Override
-        public final int getBack() {
-            return back;
-        }
-
-        @Override
-        public final int getFlags() {
-            return flags;
-        }
-
-        @Override
-        public final int getFont() {
-            return font;
-        }
-
-        @Override
-        public Color getComputedFore() {
-            return null;
-        }
-
-        @Override
-        public Color getComputedBack() {
-            return null;
-        }
-
-        @Override
-        public Font getComputedFont() {
-            return null;
-        }
-        
-    }
-    
-    public static class Mutable extends AnsiAttr {
-        
-        private static final long serialVersionUID = 1L;
-        
-        protected int back;
-        protected int fore;
-        protected int font;
-        protected int flags;
-        
-        public Mutable() {
-            this(0, 0, 0, AnsiAttr.NORMAL);
-        }
-        
-        public Mutable(int back, int fore, int font, int flags) {
-            this.back = back;
-            this.fore = fore;
-            this.font = font;
-            this.flags = flags;
-        }
-
-        @Override
-        public final int getFore() {
-            return fore;
-        }
-
-        @Override
-        public final int getBack() {
-            return back;
-        }
-
-        @Override
-        public final int getFlags() {
-            return flags;
-        }
-
-        @Override
-        public final int getFont() {
-            return font;
-        }
-
-        @Override
-        public Color getComputedFore() {
-            return null;
-        }
-
-        @Override
-        public Color getComputedBack() {
-            return null;
-        }
-
-        @Override
-        public Font getComputedFont() {
-            return null;
-        }
-        
-    }
-    
-
-}

+ 0 - 93
assira1/src/main/java/net/ranides/assira/text_format/AnsiBuilder.java

@@ -1,93 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import net.ranides.assira.text.StringUtils;
-
-/**
- *
- * @author ranides
- */
-public class AnsiBuilder extends AnsiString {
-    
-    private static final long serialVersionUID = 3L;
-    
-    private int position;
-    
-    public AnsiBuilder() {
-        this(16);
-    }
-    
-    public AnsiBuilder(int capacity) {
-        super(capacity);
-        position = 0;
-    }
-    
-    public AnsiBuilder append(AnsiCharSequence seq) {
-        int count = seq.length();
-        checkCapacityFor(count);
-        for(int i=0; i<count; i++) {
-            text[position] = seq.charAt(i);
-            backList[position] = (byte)seq.getBackAt(i);
-            foreList[position] = (byte)seq.getForeAt(i);
-            flagList[position] = (char)seq.getFlagsAt(i);
-            fontList[position] = (byte)seq.getFontAt(i);
-            position++;
-        }
-        return this;
-    }
-    
-    public AnsiBuilder append(CharSequence seq, AnsiAttr attributes) {
-        int count = seq.length();
-        checkCapacityFor(count);
-        
-        setAttr(position, position+count, attributes);
-        replace(position, seq);
-        position += count;
-        return this;
-    }
-    
-    public AnsiBuilder append(int count, char ch, AnsiAttr attributes) {
-        checkCapacityFor(count);
-        
-        setAttr(position, position+count, attributes);
-        replace(position, StringUtils.nCopies(count, ch));
-        position += count;
-        return this;
-    }
-
-    protected void checkCapacityFor(int count) {
-        int capacity = position + count;
-        if(capacity >= text.length ) {
-            
-            char[] newText = new char[capacity];
-            byte[] newForeList = new byte[capacity];
-            byte[] newBackList = new byte[capacity];
-            char[] newFlagList = new char[capacity];
-            byte[] newFontList = new byte[capacity];
-            
-            System.arraycopy(text, 0, newText, 0, text.length);
-            System.arraycopy(foreList, 0, newForeList, 0, foreList.length);
-            System.arraycopy(backList, 0, newBackList, 0, backList.length);
-            System.arraycopy(flagList, 0, newFlagList, 0, flagList.length);
-            System.arraycopy(fontList, 0, newFontList, 0, fontList.length);
-            
-            text = newText;
-            foreList = newForeList;
-            backList = newBackList;
-            flagList = newFlagList;
-            fontList = newFontList;
-        }
-
-    }
-    
-    public AnsiString result() {
-        AnsiString ret = new AnsiString(text, backList, foreList, flagList, fontList, position);
-        ret.setScheme(scheme);
-        return ret;
-    }
-}

+ 0 - 495
assira1/src/main/java/net/ranides/assira/text_format/AnsiCharSequence.java

@@ -1,495 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.io.Serializable;
-import java.util.Iterator;
-import net.ranides.assira.math.Bitwise;
-
-/**
- * Klasa reprezentująca ciąg znaków razem z przypisanymi do nich atrybutami 
- * (kolor tekstu, tła, czcionka, styl)
- * @author ranides
- */
-public abstract class AnsiCharSequence implements CharSequence, Serializable {
-    
-    private static final long serialVersionUID = 4L;
-    
-    private int hash;
-    
-    /**
-     * Odczytuje z sekwencji znak o podanym indeksie. Zwraca wynik identyczny jak
-     * {@link #charAt}. Metoda istniejąca w celu uzyskania pełnej kompatybilności
-     * sekwencji znaków z konwencją JavaBeans.
-     * @param index
-     * @return
-     */
-    public abstract char getCharAt(int index);
-    
-    /**
-     * Zwraca numer koloru tekstu przypisany do znaku o podanym indeksie. 
-     * Numer może być zamieniony na graficzną reprezentację za pomocą {@link AnsiColorScheme}.
-     * @see #getComputedForeAt 
-     * @param index
-     * @return
-     */
-    public abstract int getForeAt(int index);
-    
-    /**
-     * Zwraca numer koloru tła przypisany do znaku o podanym indeksie. 
-     * Numer może być zamieniony na graficzną reprezentację za pomocą {@link AnsiColorScheme}.
-     * @see #getComputedBackAt
-     * @param index
-     * @return
-     */
-    public abstract int getBackAt(int index);
-    
-    /**
-     * Zwraca atrybuty przypisane do znaku o podanym indeksie. 
-     * @param index
-     * @return
-     */
-    public abstract int getFlagsAt(int index);
-    
-    /**
-     * Zwraca numer czcionki przypisany do znaku o podanym indeksie. 
-     * Numer może być zamieniony na graficzną reprezentację za pomocą {@link AnsiFontScheme}.
-     * @see #getComputedFontAt
-     * @param index
-     * @return
-     */
-    public abstract int getFontAt(int index);
-    
-    /**
-     * Zwraca wszystkie właściwości przypisane do znaku o podanym indeksie
-     * (kolor, tło, czcionka, styl).
-     * @param index
-     * @return
-     */
-    public final AnsiAttr getAttrAt(int index) {
-        return new AttrView(index);
-    }
-    
-    /**
-     * Metoda opcjonalna: zwraca kolor tekstu przypisany do znaku o podanym indeksie.
-     * Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany 
-     * z odpowiednim schematem kolorów
-     * ({@link AnsiColorScheme}.
-     * @param index
-     * @return
-     */
-    public abstract Color getComputedForeAt(int index);
-    
-    /**
-     * Metoda opcjonalna: zwraca kolor tła przypisany do znaku o podanym indeksie.
-     * Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany 
-     * z odpowiednim schematem kolorów
-     * ({@link AnsiColorScheme}.
-     * @param index
-     * @return
-     */
-    public abstract Color getComputedBackAt(int index);    
-
-    /**
-     * Metoda opcjonalna: zwraca numer czcionki przypisany do znaku o podanym indeksie.
-     * Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany 
-     * z odpowiednim schematem czcionek
-     * ({@link AnsiFontScheme}.
-     * @param index
-     * @return
-     */
-    public abstract Font getComputedFontAt(int index);
-    
-    /**
-     * Zwraca schemat kolorów skojarzony z sekwencją znaków. Schemat powiązany
-     * z sekwencją odpowiada za prawidłowe działanie metod {@link #getComputedFore},
-     * {@link #getComputedBack}, {@link #getComputedFont} oraz pochodnych.
-     * @return
-     */
-    public abstract AnsiScheme getScheme();
-    
-    public abstract void setScheme(AnsiScheme scheme);
-    
-    public abstract void setCharAt(int index, char value);
-    
-    public void replace(int index, CharSequence value) {
-        for(int i=0, n = value.length(); i<n; i++) {
-            setCharAt(index+i, value.charAt(i));
-        }
-    }
-    
-    public void setBackAt(int index, int color) {
-        setBack(index, index+1, color);
-    }
-    
-    public void setForeAt(int index, int color) {
-        setFore(index, index+1, color);
-    }
-    
-    public void setFontAt(int index, int font) {
-        setFont(index, index+1, font);
-    }
-    
-    public void setFlagsAt(int index, int flags) {
-        setFlags(index, index+1, flags);
-    }
-    
-    public void setAttrAt(int index, AnsiAttr attr) {
-        setBackAt(index, attr.getBack());
-        setForeAt(index, attr.getFore());
-        setFontAt(index, attr.getFont());
-        setFlagsAt(index, attr.getFlags());
-    }
-
-    public abstract void setBack(int from, int to, int attr);
-    
-    public abstract void setFore(int from, int to, int attr);
-    
-    public abstract void setFont(int from, int to, int font);
-    
-    public abstract void setFlags(int from, int to, int flags);
-    
-    public final void setAttr(int from, int to, AnsiAttr attr) {
-        setBack(from, to, attr.getBack());
-        setFore(from, to, attr.getFore());
-        setFont(from, to, attr.getFont());
-        setFlags(from, to, attr.getFlags());
-    }
-    
-    /**
-     * Rozbija tekst na fragmenty według kryterium {@link AnsiAttr#CMP_ALL}
-     * @return
-     */
-    public final Iterable<AnsiRegion> regions() {
-        return regions(AnsiAttr.CMP_ALL);
-    }
-    
-    /**
-     * <p>
-     * Rozbija tekst na fragmenty zawierające znaki zgrupowane według kryteriów 
-     * podanych w opcjach. Opcje są zbiorem flag z klasy {@link AnsiAttr}.
-     * </p><p>
-     * Rozdziela tekst na fragmenty o jednym kolorze tekstu i tła:<br/>
-     * {@code text.split(AnsiAttr.CMP_FORE | AnsiAttr.CMP_BACK)}
-     * </p><p>
-     * Rozdziela tekst na fragmenty o tym samym stylu pogrubienia:<br/>
-     * {@code text.split(AnsiAttr.CMP_FLAGS | AnsiAttr.BOLD)}
-     * </p>
-     * @param options
-     * @return
-     */
-    public Iterable<AnsiRegion> regions(final int options) {
-        return new Iterable<AnsiRegion>() {
-            @Override
-            public Iterator<AnsiRegion> iterator() {
-                return new RegionIterator(options);
-            }
-        };
-    }
-    
-    @Override
-    public final char charAt(int index) {
-        return getCharAt(index);
-    }
-    
-    @Override
-    public AnsiCharSequence subSequence(int begin, int end) {
-        return new Fragment(this, begin, end);
-    }
-    
-    @Override
-    public int hashCode() {
-        int h = hash;
-        int n = length();
-        if (h == 0 && n>0) {
-            for (int i = 0; i < n; i++) {
-                h = 31 * h + charAt(i) + 37 * getBackAt(i) + 53 * getForeAt(i);
-            }
-            hash = h;
-        }
-        return h;
-    }
-
-    @Override
-    public boolean equals(Object object) {
-        if(object instanceof AnsiCharSequence) {
-            return equals((AnsiCharSequence)object, AnsiAttr.CMP_PUBLIC);
-        }
-        return false;
-    }
-    
-    public boolean equals(AnsiCharSequence value, int flags) {
-        if( this == value ) { // NOPMD
-            return true;
-        }
-        if( value.length() != length() ) {
-            return false;
-        }
-        for(int i=0, n=value.length(); i<n; i++) {
-            if (Bitwise.has(flags, AnsiAttr.CMP_CHAR) && value.charAt(i) != charAt(i)) {
-                return false;
-            }
-            if( !value.getAttrAt(i).equals(getAttrAt(i), flags) ) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public final String toString() {
-        return new StringBuilder(length()).append(this).toString();
-    }
-    
-    
-    private class RegionIterator implements Iterator<AnsiRegion> {
-        
-        private final int options;
-        private int index = 0;
-
-        public RegionIterator(int options) {
-            this.options = options;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return index < AnsiCharSequence.this.length();
-        }
-
-        @Override
-        @SuppressWarnings("PMD.CyclomaticComplexity")
-        public AnsiRegion next() {
-            final int start = index;
-            final AttrView attr = new AttrView(start);
-            final boolean sfc = Bitwise.has(options, AnsiAttr.CMP_FORE);
-            final boolean sfb = Bitwise.has(options, AnsiAttr.CMP_BACK);
-            final boolean sfs = Bitwise.has(options, AnsiAttr.CMP_FLAGS);
-            final boolean sff = Bitwise.has(options, AnsiAttr.CMP_FONT);
-            
-            index++;
-            int max = AnsiCharSequence.this.length();
-            while(index<max) {
-                if( sfc && getForeAt(index)!=attr.getFore()) { break; }
-                if( sfb && getBackAt(index)!=attr.getBack() ) { break;  }
-                if( sfs && (getFlagsAt(index) & options)!=(attr.getFlags()&options)) { break; }
-                if( sff && getFontAt(index)!=attr.getFont()) { break; }
-                index++;
-            }
-            
-            return new AnsiRegion(attr, subSequence(start, index));
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException("Strings are immutable.");
-        }
-    }
-    
-    private class AttrView extends AnsiAttr {
-        
-        private static final long serialVersionUID = 3L;
-        
-        private final int index;
-
-        /**
-         * Tworzy obiekt reprezentujący atrybuty znaku o podanym indeksie, zapisanego
-         * w podanej sekwencji. Modyfikacja powiązanej sekwencji natychmiast jest
-         * widoczna w obiekcie.
-         * @param sequence
-         * @param index
-         */
-        public AttrView(int index) {
-            this.index = index;
-        }
-
-        @Override
-        public Color getComputedBack() {
-            return getComputedBackAt(index);
-        }
-
-        @Override
-        public Font getComputedFont() {
-            return getComputedFontAt(index);
-        }
-
-        @Override
-        public Color getComputedFore() {
-            return getComputedForeAt(index);
-        }
-
-        @Override
-        public int getFlags() {
-            return getFlagsAt(index);
-        }
-
-        @Override
-        public int getBack() {
-            return getBackAt(index);
-        }
-
-        @Override
-        public int getFont() {
-            return getFontAt(index);
-        }
-
-        @Override
-        public int getFore() {
-            return getForeAt(index);
-        }
-        
-    }
-    
-    private class Fragment extends AnsiCharSequence {
-
-        private static final long serialVersionUID = 3L;
-
-        protected final AnsiCharSequence source;
-        protected final int left;
-        protected final int right;
-
-        public Fragment(AnsiCharSequence source, int left, int right) {
-            this.source = source;
-            this.left = left;
-            this.right = right;
-        }
-
-        @Override
-        public Color getComputedForeAt(int index) {
-            return source.getComputedForeAt(left + index);
-        }
-
-        @Override
-        public Color getComputedBackAt(int index) {
-            return source.getComputedBackAt(left + index);
-        }
-
-        @Override
-        public int getForeAt(int index) {
-            return source.getForeAt(left + index);
-        }
-
-        @Override
-        public int getBackAt(int index) {
-            return source.getBackAt(left + index);
-        }
-
-        @Override
-        public int getFlagsAt(int index) {
-            return source.getFlagsAt(left + index);
-        }
-
-        @Override
-        public Font getComputedFontAt(int index) {
-            return source.getComputedFontAt(left + index);
-        }
-
-        @Override
-        public int getFontAt(int index) {
-            return source.getFontAt(left + index);
-        }
-
-        @Override
-        public AnsiCharSequence subSequence(int begin, int end) {
-            return new Fragment(source, left+begin, left+end);
-        }
-
-        @Override
-        public int length() {
-            return right - left;
-        }
-
-        @Override
-        public char getCharAt(int index) {
-            return source.charAt(left + index);
-        }
-
-        @Override
-        public AnsiScheme getScheme() {
-            return source.getScheme();
-        }
-
-        @Override
-        public void setScheme(AnsiScheme scheme) {
-            source.setScheme(scheme);
-        }
-
-        @Override
-        public void setCharAt(int index, char value) {
-            source.setCharAt(left + index, value);
-        }
-        
-        @Override
-        public void setBackAt(int index, int color) {
-            source.setBackAt(left+index, color);
-        }
-
-        @Override
-        public void setForeAt(int index, int color) {
-            source.setForeAt(left+index, color);
-        }
-
-        @Override
-        public void setFontAt(int index, int font) {
-            source.setFontAt(left+index, font);
-        }
-
-        @Override
-        public void setFlagsAt(int index, int flags) {
-            source.setFlagsAt(left+index, flags);
-        }
-
-        @Override
-        public void setAttrAt(int index, AnsiAttr attr) {
-            source.setAttrAt(left+index, attr);
-        }
-
-        @Override
-        public void setBack(int from, int to, int attr) {
-            source.setBack(left + from, left + to, attr);
-        }
-
-        @Override
-        public void setFore(int from, int to, int attr) {
-            source.setFore(left + from, left + to, attr);
-        }
-
-        @Override
-        public void setFont(int from, int to, int font) {
-            source.setFont(left + from, left + to, font);
-        }
-
-        @Override
-        public void setFlags(int from, int to, int flags) {
-            source.setFlags(left + from, left + to, flags);
-        }
-        
-        @Override
-        public boolean equals(Object object) {
-            if(this == object) {
-                    return true;
-                }
-            if (object instanceof Fragment) {
-                final Fragment other = (Fragment)object;
-                if( source == other.source )  {
-                    return (left == other.left) && (right == other.right);
-                }
-            }
-            return super.equals(object);
-        }
-
-        @Override
-        public int hashCode() {
-            return super.hashCode();
-        }
-        
-        
-
-    }
-}

+ 0 - 66
assira1/src/main/java/net/ranides/assira/text_format/AnsiMatch.java

@@ -1,66 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.io.Serializable;
-import java.util.regex.Matcher;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class AnsiMatch implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    
-    private final AnsiCharSequence source;
-    
-    private final int[] groups;
-    
-    AnsiMatch(AnsiCharSequence source, int start, int end) {
-        this.source = source;
-        this.groups = new int[]{start, end};
-    }
-    
-    AnsiMatch(AnsiCharSequence source, Matcher hit) {
-        this.source = source;
-        this.groups = new int[2*hit.groupCount()+2];
-        for(int i=0, n=hit.groupCount(); i<=n; i++) {
-            this.groups[2*i+0] = hit.start(i);
-            this.groups[2*i+1] = hit.end(i);
-        }
-    }
-    
-    public AnsiCharSequence value() {
-        return source.subSequence(begin(), end());
-    }
-    
-    public AnsiCharSequence group(int index) {
-        return source.subSequence(begin(index), end(index));
-    }
-    
-    public int groups() {
-        return groups.length / 2 - 1;
-    }
-    
-    public int begin(int index) {
-        return groups[2*index];
-    }
-    
-    public int end(int index) {
-        return groups[2*index+1];
-    }
-    
-    public int begin() {
-        return groups[0];
-    }
-    
-    public int end() {
-        return groups[1];
-    }
-    
-}

+ 0 - 153
assira1/src/main/java/net/ranides/assira/text_format/AnsiPattern.java

@@ -1,153 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import net.ranides.assira.collection.VirtualIterator;
-import net.ranides.assira.text.Strings;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public abstract class AnsiPattern implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    
-    public Iterable<AnsiMatch> find(final AnsiCharSequence input) {
-        return new Iterable<AnsiMatch>() {
-            @Override
-            public Iterator<AnsiMatch> iterator() {
-                return AnsiPattern.this.iterator(input);
-            }
-        };
-    }
-    
-    public boolean matches(AnsiCharSequence input) {
-        return find(input).iterator().hasNext();
-    }
-    
-    public boolean apply(AnsiCharSequence input, AnsiAttr attribute) {
-        boolean ret = false;
-        for(AnsiMatch item : find(input)) {
-            ret = true;
-            if( item.groups()>0 ) {
-                for(int i=1; i<=item.groups(); i++) {
-                    AnsiStrings.apply(item.group(i), attribute);
-                }
-            } else {
-                AnsiStrings.apply(item.value(), attribute);
-            }
-        }
-        return ret;
-    }
-    
-    protected abstract Iterator<AnsiMatch> iterator(AnsiCharSequence input);
-    
-    public static class REPattern extends AnsiPattern implements Serializable {
-        
-        private static final long serialVersionUID = 1L;
-        
-        private final Pattern regex;
-        
-        public REPattern(String regex) {
-            this.regex = Pattern.compile(regex);
-        }
-        
-        public REPattern(String regex, int flags) {
-            this.regex = Pattern.compile(regex, flags);
-        }
-
-        public REPattern(Pattern regex) {
-            this.regex = regex;
-        }
-        
-        @Override
-        public Iterator<AnsiMatch> iterator(final AnsiCharSequence input) {
-            return new RIterator(input, regex);
-        }
-        
-        public String pattern() {
-            return this.regex.pattern();
-        }
-        
-        public int flags() {
-            return this.regex.flags();
-        }
-            
-    }
-    
-    public static class MSPattern extends AnsiPattern implements Serializable {
-        
-        private static final long serialVersionUID = 1L;
-        
-        private final String pattern;
-
-        public MSPattern(String pattern) {
-            this.pattern = pattern;
-        }
-        
-        @Override
-        public Iterator<AnsiMatch> iterator(final AnsiCharSequence input) {
-            return new SIterator(input, pattern);
-        }
-        
-        public String pattern() {
-            return pattern;
-        }
-            
-    }
-    
-    private static class SIterator extends VirtualIterator<AnsiMatch> {
-
-        private final AnsiCharSequence input; 
-        private final String pattern;
-        private int offset = -1;
-
-        public SIterator(AnsiCharSequence input, String pattern) {
-            this.input = input;
-            this.pattern = pattern;
-        }
-        
-        @Override
-        public AnsiMatch get() {
-            offset = Strings.indexOf(input, pattern, offset+1);
-            if(-1 == offset) {
-                return null;
-            } else {
-                return new AnsiMatch(input, offset, offset+pattern.length());
-            }
-        }
-
-    }
-    
-    private static class RIterator extends VirtualIterator<AnsiMatch> {
-        
-        private final AnsiCharSequence input; 
-        private final Matcher matcher;
-
-        public RIterator(AnsiCharSequence input, Pattern pattern) {
-            this.input = input;
-            this.matcher = pattern.matcher(input);
-        }
-        
-        @Override
-        protected AnsiMatch get() {
-            if( !matcher.find() ) {
-                return null;
-            } else {
-                return new AnsiMatch(input, matcher);
-            }
-        }
-        
-    }
-    
-    
-}

+ 0 - 40
assira1/src/main/java/net/ranides/assira/text_format/AnsiRegion.java

@@ -1,40 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.io.Serializable;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class AnsiRegion implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    
-    private final AnsiAttr attr;
-    private final AnsiCharSequence value;
-
-    AnsiRegion(AnsiAttr attr, AnsiCharSequence value) {
-        this.value = value;
-        this.attr = attr;
-    }
-
-    public AnsiAttr attr() {
-        return attr;
-    }
-
-    public AnsiCharSequence value() {
-        return value;
-    }
-
-    @Override
-    public String toString() {
-        return "Region{" + "attr=" + attr + ", value=" + value + '}';
-    }
-    
-}

+ 0 - 160
assira1/src/main/java/net/ranides/assira/text_format/AnsiScheme.java

@@ -1,160 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import net.ranides.assira.generic.ValueUtils;
-import net.ranides.assira.math.HashHelper;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class AnsiScheme implements Serializable {
-    
-    private static final long serialVersionUID = 0x401L;
-    
-    public static final AnsiScheme DEFAULT = new AnsiScheme();
-    
-    private final Map<Integer, Color> colors;
-    
-    private final Map<Integer, Font> fonts;
-    
-    public AnsiScheme() {
-        colors = new HashMap<>();
-        fonts = new HashMap<>();
-    }
-    
-    public AnsiScheme(AnsiScheme scheme) {
-        colors = new HashMap<>(scheme.colors);
-        fonts = new HashMap<>(scheme.fonts);
-    }
-
-    public Collection<Color> colors() {
-        return colors.values();
-    }
-    
-    public Collection<Font> fonts() {
-        return fonts.values();
-    }
-    
-    public Color getColor(int index) {
-        return colors.containsKey(index) ? colors.get(index) : null;
-    }
-    
-    public Font getFont(int index) {
-        return fonts.containsKey(index) ? fonts.get(index) : null;
-    }
-    
-    public void setColor(int index, Color color) {
-        if(0 == index) {
-            throw new IllegalArgumentException("default entry is immutable");
-        }
-        colors.put(index, color);
-    }
-    
-    public void setFont(int index, Font font) {
-        if(0 == index) {
-            throw new IllegalArgumentException("default entry is immutable");
-        }
-        fonts.put(index, font);
-    }
-    
-    public int addColor(Color color) {
-        int i = colors.size() + 1;
-        while(colors.containsKey(i)) {
-            i++;
-        }
-        colors.put(i, color);
-        return i;
-    }
-    
-    public int addFont(Font font) {
-        int i = fonts.size() + 1;
-        while(fonts.containsKey(i)) {
-            i++;
-        }
-        fonts.put(i, font);
-        return i;
-    }
-    
-    public AnsiSchemeAttr addAttr(Color back, Color fore, Font font, int flags) {
-        return new AnsiSchemeAttr(addColor(back), addColor(fore), addFont(font), flags);
-    }
-    
-    public AnsiSchemeAttr compute(AnsiAttr value) {
-        return new AnsiSchemeAttr(value.getBack(), value.getFore(), value.getFont(), value.getFlags());
-    }
-
-    @Override
-    public int hashCode() {
-        return HashHelper.hashValues(7, 83, colors, fonts);
-    }
-
-    @Override
-    public boolean equals(Object object) {
-        if(!(object instanceof AnsiScheme)) {
-            return false;
-        }
-        AnsiScheme value = (AnsiScheme)object;
-        return 
-            ValueUtils.equals(colors, value.colors) &&
-            ValueUtils.equals(fonts, value.fonts);
-    }
-    
-    
-    
-    public class AnsiSchemeAttr extends AnsiAttr.Mutable {
-        
-        private static final long serialVersionUID = 4L;
-        
-        public AnsiSchemeAttr(int back, int fore, int font, int flags) {
-            this.back = back;
-            this.fore = fore;
-            this.font = font;
-            this.flags = flags;
-        }
-        
-        @Override
-        public Color getComputedFore() {
-            return AnsiScheme.this.getColor(fore);
-        }
-
-        @Override
-        public Color getComputedBack() {
-            return AnsiScheme.this.getColor(back);
-        }
-
-        @Override
-        public Font getComputedFont() {
-            return AnsiScheme.this.getFont(font);
-        }
-        
-        public void setFont(Font value) {
-            AnsiScheme.this.setFont(font, value);
-        }
-        
-        public void setFore(Color value) {
-            AnsiScheme.this.setColor(fore, value);
-        }
-        
-        public void setBack(Color value) {
-            AnsiScheme.this.setColor(back, value);
-        }
-        
-        public void setFlags(int value) {
-            this.flags = value;
-        }
-
-    }
-    
-}

+ 0 - 239
assira1/src/main/java/net/ranides/assira/text_format/AnsiString.java

@@ -1,239 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/
- */
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.util.Arrays;
-import net.ranides.assira.math.Bitwise;
-
-/**
- *
- * @author ranides
- */
-public class AnsiString extends AnsiCharSequence {
-
-    private static final long serialVersionUID = 0x202L;
-
-    protected enum Init { DIRECT };
-    
-    protected char[] text;
-    protected byte[] foreList; 
-    protected byte[] backList; 
-    protected char[] flagList; 
-    protected byte[] fontList; 
-    
-    protected AnsiScheme scheme = AnsiScheme.DEFAULT;
-
-    public AnsiString(AnsiCharSequence sequence) {
-        this(sequence, 0, sequence.length());
-    }
-    
-    public AnsiString(String text) {
-        this(Init.DIRECT, text.toCharArray());
-    }
-    
-    public AnsiString(AnsiCharSequence source, int begin, int end) {
-        if (source instanceof AnsiString) {
-            AnsiString str  = (AnsiString)source;
-            this.scheme     = str.scheme;
-            this.text       = Arrays.copyOfRange(str.text, begin, end);
-            this.foreList   = Arrays.copyOfRange(str.foreList, begin, end);
-            this.backList   = Arrays.copyOfRange(str.backList, begin, end);
-            this.flagList   = Arrays.copyOfRange(str.flagList, begin, end);
-            this.fontList   = Arrays.copyOfRange(str.fontList, begin, end);
-        } else {
-            int count       = end-begin;
-            this.scheme     = source.getScheme();
-            this.text       = new char[count];
-            this.foreList   = new byte[count];
-            this.backList   = new byte[count];
-            this.flagList   = new char[count];
-            this.fontList   = new byte[count];
-            for(int i=0; i<count; i++) {
-                int offset = i+begin;
-                this.text[i]        = source.charAt(offset);
-                this.foreList[i]    = (byte)source.getForeAt(offset);
-                this.backList[i]    = (byte)source.getBackAt(offset);
-                this.flagList[i]    = (char)source.getFlagsAt(offset);
-                this.fontList[i]    = (byte)source.getFontAt(offset);
-            }
-        }
-    }
-    
-    @SuppressWarnings("PMD")
-    protected AnsiString(Init _i, char[] text) {
-        this.text       = text;
-        this.foreList   = new byte[ text.length ];
-        this.backList   = new byte[ text.length ];
-        this.flagList   = new char[ text.length ];
-        this.fontList   = new byte[ text.length ];
-    }
-    
-    protected AnsiString(char[] text, byte[] backList, byte[] foreList, char[] flagList, byte[] fontList, int size) {
-        this.text       = Arrays.copyOf(text, size);
-        this.foreList   = Arrays.copyOf(foreList, size);
-        this.backList   = Arrays.copyOf(backList, size);
-        this.flagList   = Arrays.copyOf(flagList, size);
-        this.fontList   = Arrays.copyOf(fontList, size);
-    }
-    
-    protected AnsiString(int capacity) {
-        this.text       = new char[capacity];
-        this.foreList   = new byte[capacity];
-        this.backList   = new byte[capacity];
-        this.flagList   = new char[capacity];
-        this.fontList   = new byte[capacity];
-    }
-
-    @Override
-    public AnsiScheme getScheme() {
-        return scheme;
-    }
-    
-    @Override
-    public Color getComputedForeAt(int index) {
-        return scheme.getColor(getForeAt(index));
-    }
-
-    @Override
-    public Color getComputedBackAt(int index) {
-        return scheme.getColor(getBackAt(index));
-    }
-    
-    @Override
-    public Font getComputedFontAt(int index) {
-        return scheme.getFont(getFontAt(index));
-    }
-    
-    @Override
-    public int getForeAt(int index) {
-        return foreList[index] & 0xFF;
-    }
-    
-    @Override
-    public int getBackAt(int index) {
-        return backList[index] & 0xFF;
-    }
-    
-    @Override
-    public int getFlagsAt(int index) {
-        return flagList[index];
-    }
-
-    @Override
-    public int getFontAt(int index) {
-        return fontList[index] & 0xFF;
-    }
-
-    @Override
-    public int length() {
-        return text.length;
-    }
-
-    @Override
-    public char getCharAt(int index) {
-        return text[index];
-    }
-    
-    @Override
-    public void setScheme(AnsiScheme scheme) {
-        this.scheme = scheme;
-    }
-    
-    @Override
-    public void setCharAt(int index, char value) {
-        text[index] = value;
-    }
-
-    @Override
-    public void setBackAt(int index, int color) {
-        backList[index] = (byte)color;
-    }
-    
-    @Override
-    public void setForeAt(int index, int color) {
-        foreList[index] = (byte)color;
-    }
-    
-    @Override
-    public void setFontAt(int index, int font) {
-        fontList[index] = (byte)font;
-    }
-    
-    @Override
-    public void setFlagsAt(int index, int flags) {
-        flagList[index] &= ~((flags & AnsiAttr.MASK_FLAGS_CLR) >> 8);
-        flagList[index] |= (flags & AnsiAttr.MASK_FLAGS_SET);
-    }
-    
-        
-    @Override
-    public void setBack(int from, int to, int attr) {
-        byte value = (byte)attr;
-        for(int i=from; i<to && i<backList.length; i++) { backList[i] = value; }
-    }
-    
-    @Override
-    public void setFore(int from, int to, int attr) {
-        byte value = (byte)attr;
-        for(int i=from; i<to && i<foreList.length; i++) { foreList[i] = value; }
-    }
-    
-    @Override
-    public void setFont(int from, int to, int font) {
-        byte value = (byte)font;
-        for (int i = from; i < to && i < fontList.length; i++) {
-            fontList[i] = value;
-        }
-    }
-    
-    @Override
-    public void setFlags(int from, int to, int flags) {
-        char clrv = (char)~(char)((flags & AnsiAttr.MASK_FLAGS_CLR) >> 8);
-        char setv = (char)(flags & AnsiAttr.MASK_FLAGS_SET);
-        for (int i = from; i < to && i < flagList.length; i++) {
-            flagList[i] &= clrv;
-            flagList[i] |= setv;
-        }
-    }
-    
-    @SuppressWarnings({
-        "PMD.NPathComplexity", 
-        "PMD.CyclomaticComplexity"
-    })
-    @Override
-    public boolean equals(AnsiCharSequence value, int flags) {
-        if( this == value ) {
-            return true;
-        }
-        if( value.length() != length() ) {
-            return false;
-        }
-        if(value instanceof AnsiString) {
-            AnsiString str = (AnsiString)value;
-            if( Bitwise.has(flags, AnsiAttr.CMP_CHAR) && !Arrays.equals(this.text, str.text)) {
-                return false;
-            }
-            if( Bitwise.has(flags, AnsiAttr.CMP_FORE) && !Arrays.equals(this.foreList, str.foreList)) {
-                return false;
-            }
-            if( Bitwise.has(flags, AnsiAttr.CMP_BACK) && !Arrays.equals(this.backList, str.backList)) {
-                return false;
-            }
-            if( Bitwise.has(flags, AnsiAttr.CMP_FONT) && !Arrays.equals(this.fontList, str.fontList)) {
-                return false;
-            }
-            if( Bitwise.has(flags, AnsiAttr.CMP_FLAGS_ALL) && !Arrays.equals(this.flagList, str.flagList)) {
-                return false;
-            }
-            return super.equals(value, flags & AnsiAttr.CMP_FLAGS_ALL);
-        }
-        return super.equals(value, flags);
-    }
-  
-}

+ 0 - 130
assira1/src/main/java/net/ranides/assira/text_format/AnsiStrings.java

@@ -1,130 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import net.ranides.assira.math.Bitwise;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class AnsiStrings {
-    
-    private AnsiStrings() {
-        // utility class
-    }
-    
-    private static final Pattern VALUE_OF_RE = Pattern.compile(
-        "(?:AnsiAttr\\{)?([0-9]+)\\s+([0-9]+)(?:\\s+([0-9]+))?(?:\\s+([a-z\\+\\- ]+)|\\s+([0-9]+))?\\}?"
-    );
-
-    private static final int VALUE_OF_INT[] = {
-        AnsiAttr.BOLD,
-        AnsiAttr.UNDERLINE,
-        AnsiAttr.INVERT,
-        AnsiAttr.SYMBOL,
-        AnsiAttr.NARROW,
-        AnsiAttr.STRIKE,
-        AnsiAttr.FRESH,
-        AnsiAttr.CHANGED,
-        
-        AnsiAttr.NO_BOLD,
-        AnsiAttr.NO_UNDERLINE,
-        AnsiAttr.NO_INVERT,
-        AnsiAttr.NO_SYMBOL,
-        AnsiAttr.NO_NARROW,
-        AnsiAttr.NO_STRIKE,
-        AnsiAttr.NO_FRESH,
-        AnsiAttr.NO_CHANGED,
-        
-        AnsiAttr.MASK_FLAGS_CLR
-    };
-    
-    private static final String VALUE_OF_STR[] = {
-        "+b",
-        "+u",
-        "+i",
-        "+m",
-        "+n",
-        "+s",
-        "+f",
-        
-        "+c",
-        "-b",
-        "-u",
-        "-i",
-        "-m",
-        "-n",
-        "-s",
-        "-f",
-        "-c",
-        
-        "r"
-    };
-    
-    public static AnsiAttr attr(int back, int fore) {
-        return AnsiStrings.attr(back, fore, 0);
-    }
-    
-    public static AnsiAttr attr(int back, int fore, int font) {
-        return AnsiStrings.attr(back, fore, font, AnsiAttr.NORMAL | AnsiAttr.MASK_FLAGS_CLR);
-    }
-    
-    public static AnsiAttr attr(int back, int fore, int font, int flags) {
-        return new AnsiAttr.Value(back, fore, font, flags);
-    }
-    
-    public static AnsiAttr attr(int back, int fore, int font, String flags) {
-        return new AnsiAttr.Value(back, fore, font, decodeFlags(flags));
-    }
-    
-    public static AnsiAttr attr(String pattern) {
-        Matcher hit = VALUE_OF_RE.matcher(pattern);
-        if(!hit.matches()) {
-            throw new IllegalArgumentException(pattern);
-        }
-        int back = Integer.parseInt(hit.group(1));
-        int fore = Integer.parseInt(hit.group(2));
-        int font = 0;
-        if(null != hit.group(3)) {
-            font = Integer.parseInt(hit.group(3));
-        }
-        return new AnsiAttr.Value(back, fore, font, decodeFlags(hit.group(4)));
-    }
-    
-    public static void apply(AnsiCharSequence text, AnsiAttr attr) {
-        text.setAttr(0, text.length(), attr);
-    }
-    
-    public static int decodeFlags(String value) {
-        if(null == value) {
-            return AnsiAttr.NORMAL;
-        }
-        int ret = 0;
-        for(int i=0, n=VALUE_OF_INT.length; i<n; i++) {
-            if( value.contains(VALUE_OF_STR[i]) ) {
-                ret |= VALUE_OF_INT[i];
-            }
-        }
-        return ret;
-    }
-    
-    public static String encodeFlags(int value) {
-        StringBuilder ret = new StringBuilder();
-        for(int i=0, n=VALUE_OF_INT.length; i<n; i++) {
-            if( Bitwise.has(value, VALUE_OF_INT[i]) ) {
-                ret.append(VALUE_OF_STR[i]);
-            }
-        }
-        return ret.toString();
-    }
-    
-    
-    
-}

+ 0 - 64
assira1/src/test/java/net/ranides/assira/config/JSONConfigurationTest.java

@@ -1,64 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import net.ranides.assira.io.FileHelper;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author ranides
- */
-public class JSONConfigurationTest {
-    
-    public JSONConfigurationTest() {
-    }
-    
-    
-
-    @Test
-    public void testSimpleRW() throws IOException {
-        File file = FileHelper.createTempFile(".example.json", JSONConfiguration.class);
-        
-        Configuration source = new JSONConfiguration("file:" + file);
-        
-        source.put(String.class, "author.name", "ranides");
-        source.put(String.class, "author.mail", "ranides@gmail.com");
-        source.put(int.class, "version.major", 1);
-        source.put(int.class, "version.minor", 27);
-        source.put(int.class, "version.build", 2043);
-        
-        assertEquals(2, ((Map)source.get("author")).size() );
-        assertEquals("ranides", source.get(String.class, "author.name"));
-        assertEquals("ranides@gmail.com", source.get(String.class, "author.mail"));
-        
-        assertEquals(3, ((Map)source.get("version")).size() );
-        
-        assertEquals((Long)1L, source.get(long.class, "version.major"));
-        assertEquals((Long)27L, source.get(long.class, "version.minor"));
-
-        source.save();
-        
-        Configuration target = new JSONConfiguration("file:" + file).load(); // ConfigService.getInstance("temp:file:"+file);
-
-        assertEquals(2, ((Map)target.get("author")).size() );
-        assertEquals("ranides", target.get(String.class, "author.name"));
-        assertEquals("ranides@gmail.com", target.get(String.class, "author.mail"));
-        
-        assertEquals(3, ((Map)target.get("version")).size() );
-        assertEquals((Long)1L, target.get(long.class, "version.major"));
-        assertEquals((Long)27L, target.get(long.class, "version.minor"));
-        
-        assertEquals((Long)55L, target.get(long.class, "version.release", 55L));
-        assertEquals("#default", target.get(String.class, "root.unknown.property", "#default"));
-        
-    }
-}

+ 0 - 47
assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.java

@@ -1,47 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.config;
-
-import java.util.Map;
-import javax.xml.transform.TransformerException;
-import net.ranides.assira.asm.AsmUtils;
-import net.ranides.assira.text.LexicalCast;
-import net.ranides.assira.text.StringLoader;
-import net.ranides.assira.trace.LoggerUtils;
-import net.ranides.assira.trace.StackInspector;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author ranides
- */
-public class XMLConfigurationTest {
-    
-    private static final String CPATH = "src/test/java/" + AsmUtils.class2p(StackInspector.frame().getClassName());
-    
-    @Test
-    public void testLoad() {
-        Configuration config = new XMLConfiguration(CPATH + ".xml").load();
-          
-        assertEquals("4.0.0", config.get("project.modelVersion") );  
-        assertEquals("jar", config.get("project.packaging") );  
-        
-        assertEquals("commons-collections", config.getList(Map.class, "project.dependencies.dependency").get(1).get("groupId") );  
-        assertEquals("joda-time", config.getList(Map.class, "project.dependencies.dependency").get(10).get("groupId") );  
-        assertEquals("joda-time", config.get("project.dependencies.dependency[10].groupId") );  
-        assertEquals("joda-time", config.get("project.dependencies[0].dependency[10].groupId") );  
-        assertEquals("UTF-8", config.get("project.properties.project.build.sourceEncoding") );  
-
-//        LoggerUtils.dump("%s\n", LexicalCast.toJSON(target));
-        
-        // ignorujemy wszystkie białe znaki, bo tylko formatują wcięcia
-        String expected = StringLoader.fromFile(CPATH + ".json").replaceAll("[ \t\n\r]", "");
-        String current = LexicalCast.toJSON(config.asMap()).replaceAll("[ \t\n\r]", "");
-        assertEquals(expected, current);
-    }
-}

+ 0 - 110
assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.json

@@ -1,110 +0,0 @@
-{
-    "project": {
-        "modelVersion": "4.0.0",
-        "groupId": "net.ranides",
-        "artifactId": "assira",
-        "version": "0.54",
-        "packaging": "jar",
-        "name": "assira",
-        "url": "http://ranides.net/projects/assira",
-        "properties": {
-            "project": {
-                "build": {
-                    "sourceEncoding": "UTF-8"
-                }
-            },
-            "netbeans": {
-                "hint": {
-                    "license": "WTFPL"
-                }
-            }
-        },
-        "build": {
-            "plugins": {
-                "plugin": ["aa", "ccc", "ddd", {
-                        "groupId": "org.apache.maven.plugins",
-                        "artifactId": "maven-pmd-plugin",
-                        "version": "2.7.1",
-                        "configuration": {
-                            "rulesets": {
-                                "ruleset": ["http://ranides.net/projects/pmd/assira.custom.xml", "http://ranides.net/projects/pmd/assira.standard.xml"]
-                            }
-                        }
-                    }, {
-                        "groupId": "org.apache.maven.plugins",
-                        "artifactId": "maven-compiler-plugin",
-                        "version": "2.3.2",
-                        "configuration": {
-                            "source": "1.6",
-                            "target": "1.6",
-                            "compilerArgument": ["-Xlint:unchecked", "-proc:none"]
-                        }
-                    }, {
-                        "groupId": "org.apache.maven.plugins",
-                        "artifactId": "maven-surefire-plugin",
-                        "version": "2.13",
-                        "configuration": {
-                            "forkMode": "pertest",
-                            "argLine": "-Xms512m -Xmx512m",
-                            "testFailureIgnore": "false",
-                            "skip": "false"
-                        }
-                    }]
-            }
-        },
-        "dependencies": {
-            "dependency": [{
-                    "groupId": "log4j",
-                    "artifactId": "log4j",
-                    "version": "1.2.16"
-                }, {
-                    "groupId": "commons-collections",
-                    "artifactId": "commons-collections",
-                    "version": "3.2.1"
-                }, {
-                    "groupId": "junit",
-                    "artifactId": "junit",
-                    "version": "4.10",
-                    "scope": "test"
-                }, {
-                    "groupId": "org.apache.commons",
-                    "artifactId": "commons-lang3",
-                    "version": "3.1"
-                }, {
-                    "groupId": "com.fasterxml.jackson.core",
-                    "artifactId": "jackson-core",
-                    "version": "2.0.1",
-                    "type": "jar"
-                }, {
-                    "groupId": "com.fasterxml.jackson.datatype",
-                    "artifactId": "jackson-datatype-json-org",
-                    "version": "2.0.0"
-                }, {
-                    "groupId": "com.google.caliper",
-                    "artifactId": "caliper",
-                    "version": "1.0L",
-                    "scope": "test"
-                }, {
-                    "groupId": "net.ranides",
-                    "artifactId": "assira.asm",
-                    "version": "4.1"
-                }, {
-                    "groupId": "findbugs",
-                    "artifactId": "annotations",
-                    "version": "1.0.0"
-                }, {
-                    "groupId": "eu.vitaliy",
-                    "artifactId": "mazovia-charset",
-                    "version": "1.0"
-                }, {
-                    "groupId": "joda-time",
-                    "artifactId": "joda-time",
-                    "version": "2.1"
-                }, {
-                    "groupId": "cglib",
-                    "artifactId": "cglib",
-                    "version": "2.2.2"
-                }]
-        }
-    }
-}

+ 0 - 134
assira1/src/test/java/net/ranides/assira/config/XMLConfigurationTest.xml

@@ -1,134 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-@author Ranides Atterwim <ranides@gmail.com>
-@copyright Ranides Atterwim
-@license WTFPL
-@url http://ranides.net/projects/assira
--->
-
-
-<project>
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>net.ranides</groupId>
-    <artifactId>assira</artifactId>
-    <version>0.54</version>
-    <packaging>jar</packaging>
-
-    <name>assira</name>
-    <url>http://ranides.net/projects/assira</url>
-    
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <netbeans.hint.license>WTFPL</netbeans.hint.license>
-    </properties>
-    
-    
-    <build>
-        <plugins>
-            <plugin>aa</plugin>
-            <plugin>ccc</plugin>
-            <plugin>ddd</plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-pmd-plugin</artifactId>
-                <version>2.7.1</version>
-                <configuration>
-                    <rulesets>
-                        <ruleset>http://ranides.net/projects/pmd/assira.custom.xml</ruleset>
-                        <ruleset>http://ranides.net/projects/pmd/assira.standard.xml</ruleset>
-                    </rulesets>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.3.2</version>
-                <configuration>
-                    <source>1.6</source>
-                    <target>1.6</target>
-                    <compilerArgument>-Xlint:unchecked</compilerArgument>
-                    <compilerArgument>-proc:none</compilerArgument>
-                </configuration>
-            </plugin>
-            <!-- Pamięć dla LFSRTest -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.13</version>
-                <configuration>
-                    <forkMode>pertest</forkMode>
-                    <argLine>-Xms512m -Xmx512m</argLine>
-                    <testFailureIgnore>false</testFailureIgnore>
-                    <skip>false</skip>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-    
-    <dependencies>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>1.2.16</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-collections</groupId>
-            <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-core</artifactId>
-            <version>2.0.1</version>
-            <type>jar</type>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.datatype</groupId>
-            <artifactId>jackson-datatype-json-org</artifactId>
-            <version>2.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.caliper</groupId>
-            <artifactId>caliper</artifactId>
-            <version>1.0L</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>net.ranides</groupId>
-            <artifactId>assira.asm</artifactId>
-            <version>4.1</version>
-        </dependency>
-        <dependency>
-            <groupId>findbugs</groupId>
-            <artifactId>annotations</artifactId>
-            <version>1.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>eu.vitaliy</groupId>
-            <artifactId>mazovia-charset</artifactId>
-            <version>1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>joda-time</groupId>
-            <artifactId>joda-time</artifactId>
-            <version>2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>cglib</groupId>
-            <artifactId>cglib</artifactId>
-            <version>2.2.2</version>
-        </dependency>
-    </dependencies>
-</project>

+ 0 - 46
assira1/src/test/java/net/ranides/assira/text/format/AnsiBuilderTest.java

@@ -1,46 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class AnsiBuilderTest {
-    
-    public AnsiBuilderTest() {
-    }
-
-    @Test
-    public void testAppend() {
-        AnsiBuilder builder = new AnsiBuilder();
-        
-        AnsiCharSequence v1 = new AnsiString("Hello");
-        v1.setAttr(0, v1.length(), AnsiStrings.attr("5 15 7 +b"));
-        builder.append(v1);
-        
-        builder.append(1, ' ', AnsiStrings.attr("6 16 8 +u"));
-        builder.append("world", AnsiStrings.attr("7 17 9 +s"));
-        builder.append("........................................", AnsiStrings.attr("1 1 1"));
-        builder.append("END", AnsiStrings.attr("1 1 1"));
-        
-        AnsiCharSequence exp = new AnsiString("Hello world........................................END");
-        exp.setAttr(0, 5, AnsiStrings.attr("5 15 7 +b"));
-        exp.setAttr(5, 6, AnsiStrings.attr("6 16 8 +u"));
-        exp.setAttr(6, 11, AnsiStrings.attr("7 17 9 +s"));
-        exp.setAttr(11, exp.length(), AnsiStrings.attr("1 1 1"));
-        
-        AnsiGenerator.dump(builder.result());
-        AnsiGenerator.dump(exp);
-        
-        assertEquals(exp, builder.result());
-    }
-    
-}

+ 0 - 71
assira1/src/test/java/net/ranides/assira/text/format/AnsiGenerator.java

@@ -1,71 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import net.ranides.assira.math.Randomizer;
-import net.ranides.assira.trace.LoggerUtils;
-
-/**
- *
- * @author ranides
- */
-public final class AnsiGenerator {
-    
-    private AnsiGenerator() {
-        // utility class
-    }
-    
-    public static final AnsiScheme SCHEME;
-    
-    static {
-        SCHEME = new AnsiScheme();
-        
-        SCHEME.setColor(1, new Color(0x888888));
-        SCHEME.setColor(2, new Color(0xFFFFFF));
-        SCHEME.setColor(3, new Color(0x880000));
-        SCHEME.setColor(4, new Color(0xFF0000));
-        SCHEME.setColor(5, new Color(0x008800));
-        SCHEME.setColor(6, new Color(0x00FF00));
-        SCHEME.setColor(7, new Color(0x000088));
-        SCHEME.setColor(8, new Color(0x0000FF));
-        
-        SCHEME.setFont(1, new Font("arial", 0, 12));
-        SCHEME.setFont(2, new Font("courier", 0, 12));
-        SCHEME.setFont(3, new Font("verdana", 0, 16));
-    }
-    
-    public static AnsiCharSequence make(String value) {
-        int n = value.length();
-        byte nc = (byte)SCHEME.colors().size();
-        byte nf = (byte)SCHEME.fonts().size();
-        char ns = 0xFF;
-        
-        byte[] back = new byte[n];
-        byte[] fore = new byte[n];
-        char[] flags = new char[n];
-        byte[] fonts = new byte[n];
-        
-        for(int i=0; i<n; i++) {
-            back[i] = Randomizer.number(nc);
-            fore[i] = Randomizer.number(nc);
-            flags[i] = Randomizer.number(ns);
-            fonts[i] = Randomizer.number(nf);
-        }
-        return new AnsiString(
-            value.toCharArray(), back, fore, flags, fonts, value.length()
-        );
-    }
-    
-    public static void dump(AnsiCharSequence text) {
-        for(AnsiRegion item : text.regions(AnsiAttr.CMP_ALL)) {
-            LoggerUtils.dump("%s\n", item.toString());
-        }
-        LoggerUtils.dump("---\n");
-    }
-}

+ 0 - 135
assira1/src/test/java/net/ranides/assira/text/format/AnsiPatternTest.java

@@ -1,135 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.util.regex.Pattern;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-@SuppressWarnings("PMD")
-public class AnsiPatternTest {
-    
-    public AnsiPatternTest() {
-    }
-
-    @Test
-    public void testMatchesString() {
-        AnsiCharSequence text = new AnsiString("Hello world 23!");
-        
-        assertTrue(new AnsiPattern.MSPattern("llo").matches(text));
-        assertTrue(new AnsiPattern.MSPattern("23!").matches(text));
-        assertFalse(new AnsiPattern.MSPattern(".llo").matches(text));
-        assertFalse(new AnsiPattern.MSPattern(".23").matches(text));
-    }
-    
-
-    @Test
-    public void testMatchesRE() {
-        AnsiCharSequence text = new AnsiString("Hello world 23!");
-        
-        assertTrue( new AnsiPattern.REPattern("l+o").matches(text) );
-        assertTrue( new AnsiPattern.REPattern("[0-9]+").matches(text) );
-        
-        assertTrue( new AnsiPattern.REPattern(".llo").matches(text) );
-        assertTrue( new AnsiPattern.REPattern(".23").matches(text) );
-        
-        assertFalse( new AnsiPattern.REPattern("llo\\?").matches(text) );
-        assertFalse( new AnsiPattern.REPattern("\\.23").matches(text) );
-    }
-    
-    @Test
-    public void testFindString() {
-        AnsiCharSequence text = new AnsiString("HellTXTo TXT world TXT!");
-        
-        for(AnsiMatch item : new AnsiPattern.MSPattern("TXT").find(text)) {
-            item.value().setCharAt(1, 'E');
-        }
-        for(AnsiMatch item : new AnsiPattern.MSPattern("TET").find(text)) {
-            item.value().setCharAt(1, 'A');
-        }
-        for(AnsiMatch item : new AnsiPattern.MSPattern("TUT").find(text)) {
-            item.value().setCharAt(1, 'Q');
-        }
-        assertEquals("HellTATo TAT world TAT!", text.toString());
-    }
-    
-    @Test
-    public void testFindRE() {
-        AnsiCharSequence text = new AnsiString("Hell4403o 871 world 82!");
-        
-        for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]+").find(text)) {
-            item.value().setCharAt(0, '$');
-        }
-        for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]").find(text)) {
-            item.value().setCharAt(0, '#');
-        }
-        for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]").find(text)) {
-            item.value().setCharAt(0, '?');
-        }
-        
-        assertEquals("Hell$###o $## world $#!", text.toString());
-    }
-    
-    @Test
-    public void testFindGroups() {
-        AnsiCharSequence text = new AnsiString("Hell4403o 871 world 825!");
-        
-        for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]([0-9]+)").find(text)) {
-            item.group(1).setCharAt(0, '$');
-        }
-        
-        assertEquals("Hell4$03o 8$1 world 8$5!", text.toString());
-    }
-    
-    @Test
-    public void testApplyString() {
-        AnsiAttr a1 = AnsiStrings.attr(1, 2);
-        AnsiAttr a2 = AnsiStrings.attr(3, 4);
-        
-        AnsiCharSequence text = new AnsiString("Hello world 23!");
-        new AnsiPattern.MSPattern("o").apply(text, a1);
-        new AnsiPattern.MSPattern("or").apply(text, a2);
-        
-        AnsiCharSequence exp = new AnsiString("Hello world 23!");
-        exp.setAttr(4, 5, a1);
-        exp.setAttr(7, 8, a1);
-        exp.setAttr(7, 9, a2);
-        assertEquals(exp, text);
-    }
-    
-    @Test
-    public void testApplyRE() {
-        AnsiAttr a1 = AnsiStrings.attr(1, 2);
-        
-        AnsiCharSequence text = new AnsiString("Hello 170 world 23!");
-        new AnsiPattern.REPattern("[0-9]+").apply(text, a1);
-        
-        AnsiCharSequence exp = new AnsiString("Hello 170 world 23!");
-        exp.setAttr(6, 9, a1);
-        exp.setAttr(16, 18, a1);
-        assertEquals(exp, text);
-    }
-    
-     @Test
-    public void testApplyGroups() {
-        AnsiAttr a1 = AnsiStrings.attr(1, 2);
-        AnsiCharSequence text = new AnsiString("Hell4403o 871 world 825!");
-        
-        new AnsiPattern.REPattern("[0-9]([0-9]+)").apply(text, a1);
-        
-        AnsiCharSequence exp = new AnsiString("Hell4403o 871 world 825!");
-        exp.setAttr(5, 8, a1);
-        exp.setAttr(11, 13, a1);
-        exp.setAttr(21, 23, a1);
-        assertEquals(exp, text);
-    }
-    
-}

+ 0 - 119
assira1/src/test/java/net/ranides/assira/text/format/AnsiSchemeTest.java

@@ -1,119 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.awt.Color;
-import java.awt.Font;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class AnsiSchemeTest {
-    
-    public AnsiSchemeTest() {
-    }
-
-    @Test
-    public void testConstruct() {
-        AnsiScheme scheme1 = new AnsiScheme();
-        
-        assertEquals(0, scheme1.colors().size());
-        assertEquals(0, scheme1.fonts().size());
-        
-        scheme1.addColor(Color.black);
-        scheme1.addColor(Color.white);
-        scheme1.addColor(Color.blue);
-        scheme1.addColor(Color.red);
-        
-        scheme1.addFont(new Font("Courier New", Font.PLAIN, 11));
-        scheme1.addFont(new Font("Verdana", Font.PLAIN, 11));
-        scheme1.addFont(new Font("Arial", Font.PLAIN, 11));
-        
-        assertEquals(4, scheme1.colors().size());
-        assertEquals(3, scheme1.fonts().size());
-        
-        scheme1.setColor(2, Color.yellow);
-        scheme1.setColor(6, Color.pink);
-        scheme1.setFont(1, new Font("Tahoma", Font.PLAIN, 11));
-        scheme1.setFont(5, new Font("Courier", Font.PLAIN, 11));
-        
-        assertEquals(5, scheme1.colors().size());
-        assertEquals(4, scheme1.fonts().size());
-        
-        assertEquals(7, scheme1.addColor(Color.orange));
-        assertEquals(6, scheme1.addFont(new Font("Courier", Font.PLAIN, 17)));
-        
-        try {
-            scheme1.setColor(0, Color.yellow);
-            fail("exception expected");
-        } catch(IllegalArgumentException ex) {
-            assertTrue(true);
-        }
-        
-        Font font = scheme1.getFont(1);
-        try {
-            scheme1.setFont(0, font);
-            fail("exception expected");
-        } catch(IllegalArgumentException ex) {
-            assertTrue(true);
-        }
-        
-        AnsiScheme scheme2 = new AnsiScheme(scheme1);
-        assertEquals(scheme1, scheme2);
-    }
-    
-    @Test
-    public void testGetters() {
-        AnsiScheme scheme = new AnsiScheme(AnsiGenerator.SCHEME);
-        assertEquals(new Color(0xFF0000), scheme.getColor(4));
-        assertNull(scheme.getColor(0));
-        assertNull(scheme.getColor(90));
-        
-        assertEquals("courier", scheme.getFont(2).getName());
-        assertNull(scheme.getFont(0));
-        assertNull(scheme.getFont(90));
-    }
-    
-    @Test
-    public void testCompute() {
-        AnsiScheme scheme = new AnsiScheme(AnsiGenerator.SCHEME);
-        AnsiAttr a1 = scheme.compute(AnsiStrings.attr("1 2 3 +b"));
-        
-        assertEquals(AnsiStrings.attr("1 2 3 +b"), a1);
-        assertEquals(new Color(0x888888), a1.getComputedBack());
-        assertEquals(new Color(0xFFFFFF), a1.getComputedFore());
-        assertEquals("verdana", a1.getComputedFont().getName());
-    }
-    
-    @Test
-    public void testStringConnection() {
-        AnsiScheme scheme = new AnsiScheme(AnsiGenerator.SCHEME);
-        
-        AnsiBuilder builder = new AnsiBuilder();
-        builder.append("Hello ", AnsiStrings.attr("1 2 3"));
-        builder.append("world!", AnsiStrings.attr("6 7 +b"));
-        
-        AnsiCharSequence text = builder.result();
-        text.setScheme(scheme);
-        
-        assertEquals(AnsiGenerator.SCHEME, text.getScheme());
-        assertSame(scheme, text.getScheme());
-        
-        assertEquals("verdana", text.getAttrAt(2).getComputedFont().getName());
-        assertEquals(new Color(0x888888), text.getAttrAt(2).getComputedBack());
-        assertEquals(new Color(0x000088), text.getAttrAt(9).getComputedFore());
-        
-        assertEquals("verdana", text.subSequence(4, 8).getAttrAt(1).getComputedFont().getName());
-        assertEquals(new Color(0x888888), text.subSequence(4, 8).getAttrAt(1).getComputedBack());
-        assertEquals(new Color(0x000088), text.subSequence(4, 8).getAttrAt(3).getComputedFore());
-        
-    }
-    
-}

+ 0 - 268
assira1/src/test/java/net/ranides/assira/text/format/AnsiStringTest.java

@@ -1,268 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.io.IOException;
-import java.util.List;
-import net.ranides.assira.collection.ListUtils;
-import net.ranides.assira.collection.list.VirtualList;
-import net.ranides.assira.generic.Serializer;
-import net.ranides.assira.text.format.AnsiRegion;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author ranides
- */
-@SuppressWarnings("PMD")
-public class AnsiStringTest {
-    
-    @Test
-    public void testCopy() {
-        AnsiString input = new AnsiString("(hello world!)");
-        
-        AnsiString c1 = new AnsiString(input);
-        
-        assertEquals(c1, input);
-        
-        input.setCharAt(0, '[');
-        input.setCharAt(input.length()-1, ']');
-        c1.setCharAt(0, '<');
-        c1.setCharAt(input.length()-1, '>');
-        
-        assertFalse(input.equals(c1));
-        assertEquals("[hello world!]", input.toString());
-        assertEquals("<hello world!>", c1.toString());
-        
-        AnsiString c2 = new AnsiString(input, 1, input.length()-1);
-        
-        c2.setCharAt(0, 'H');
-        c2.setCharAt(c2.length()-1, '?');
-        assertEquals("[hello world!]", input.toString());
-        assertEquals("<hello world!>", c1.toString());
-        assertEquals("Hello world?", c2.toString());
-        
-        AnsiCharSequence s1 = input.subSequence(1, input.length()-2);
-        AnsiString c3 = new AnsiString(s1, 3, s1.length()-1);
-        assertEquals("lo worl", c3.toString());
-    }
-    
-    @Test
-    public void testCapacity() {
-        AnsiString text = new AnsiString(4);
-        text.setCharAt(0, 'h');
-        text.setCharAt(1, 'o');
-        text.setCharAt(2, 'm');
-        text.setCharAt(3, 'e');
-        text.setFore(0, 4, 33);
-        text.setBack(0, 4, 17);
-        
-        assertEquals("home", text.toString());
-        assertEquals(4, text.length());
-    }
-    
-    @Test
-    public void testCompare() {
-        AnsiString v1 = new AnsiString("home");
-        v1.setFore(0, 4, 33);
-        v1.setBack(0, 4, 17);
-        
-        assertEquals("home", v1.toString());
-        
-        AnsiString v2 = new AnsiString("home");
-        assertTrue( v1.equals(v2, AnsiAttr.CMP_CHAR) );
-        assertFalse( v1.equals(v2, AnsiAttr.CMP_PUBLIC) );
-        
-        AnsiString v3 = new AnsiString("data");
-        v3.setFore(0, 4, 33);
-        v3.setBack(0, 4, 17);
-        v3.setFlags(0, 4, AnsiAttr.FRESH);
-        
-        assertFalse( v1.equals(v3, AnsiAttr.CMP_CHAR) );
-        assertTrue( v1.equals(v3, AnsiAttr.CMP_FORE | AnsiAttr.CMP_BACK) );
-        assertTrue( v1.equals(v3, AnsiAttr.CMP_FLAGS_PUBLIC) );
-        assertFalse( v1.equals(v3, AnsiAttr.CMP_FLAGS_ALL) );
-        
-        AnsiCharSequence v4 = v3.subSequence(0, 4);
-        assertFalse( v1.equals(v4, AnsiAttr.CMP_CHAR) );
-        assertTrue( v1.equals(v4, AnsiAttr.CMP_FORE | AnsiAttr.CMP_BACK) );
-        assertTrue( v1.equals(v4, AnsiAttr.CMP_FLAGS_PUBLIC) );
-        assertFalse( v1.equals(v4, AnsiAttr.CMP_FLAGS_ALL) );
-        
-        AnsiCharSequence v5 = new AnsiString("homes");
-        assertFalse(v1.equals(v5));
-        
-        AnsiCharSequence v6 = new AnsiString("home");
-        AnsiCharSequence v7 = new AnsiString("home");
-        v6.setFont(0, 1, 19);
-        v6.setFont(2, 4, 21);
-        v7.setFont(0, 1, 17);
-        v7.setFont(2, 4, 21);
-        
-        assertTrue( v6.equals(v7, AnsiAttr.CMP_CHAR));
-        assertFalse( v6.equals(v7, AnsiAttr.CMP_FONT));
-        
-        assertFalse( v6.equals(v7) );
-        assertTrue( v6.subSequence(2, 4).equals(v7.subSequence(2, 4)));
-    }
-    
-    @Test
-    public void testFlags() {
-        AnsiString text = new AnsiString("Hello world!");
-        text.setFlags(0, 5, AnsiAttr.BOLD);
-        text.setFlags(2, 12, AnsiAttr.NARROW);
-        text.setFlags(8, 12, AnsiAttr.UNDERLINE | AnsiAttr.NO_NARROW);
-        
-        assertEquals(AnsiAttr.BOLD, text.getFlagsAt(1));
-        assertEquals(AnsiAttr.BOLD | AnsiAttr.NARROW, text.getFlagsAt(3));
-        assertEquals(AnsiAttr.NARROW, text.getFlagsAt(6));
-        assertEquals(AnsiAttr.UNDERLINE, text.getFlagsAt(9));
-    }
-
-    @Test
-    public void testSubsequence() {
-        AnsiString text = new AnsiString("(hello world!)");
-        
-        AnsiCharSequence a = text.subSequence(1, text.length()-1);
-        
-        AnsiCharSequence b = a.subSequence(6, a.length()-1);
-        
-        AnsiCharSequence c = text.subSequence(6, text.length()-1);
-                
-        assertEquals("hello world!", a.toString());
-        
-        assertEquals("world", b.toString());
-        
-        assertEquals(" world!", c.toString());
-        
-        text.setCharAt(1, 'H');
-        
-        text.setCharAt(7, 'W');
-        
-        text.setCharAt(12, '?');
-        
-        assertEquals("Hello World?", a.toString());
-        
-        assertEquals("World", b.toString());
-        
-        assertEquals(" World?", c.toString());
-        
-        a.setAttr(1, 4, AnsiStrings.attr("3 4 +b"));
-        a.replace(1, "ouse");
-        
-        assertEquals("(House World?)", text.toString());
-        
-        AnsiString exp = new AnsiString("(House World?)");
-        exp.setAttr(2, 5, AnsiStrings.attr("3 4 +b"));
-        
-        assertEquals(exp, text);
-        
-        assertTrue( a.equals(a) );
-        assertTrue( text.subSequence(1, 5).equals(text.subSequence(1, 5)) );
-        assertFalse( text.subSequence(1, 5).equals(text.subSequence(1, 6)) );
-        assertFalse( text.subSequence(1, 5).equals(text) );
-    }
-    
-    @Test
-    public void testSerialization() throws IOException {
-        AnsiCharSequence sequence = AnsiGenerator.make("Hello world!");
-        AnsiCharSequence input = sequence.subSequence(3, 7);
-        
-        AnsiCharSequence output = Serializer.copy(input);
-        
-        assertEquals(input, output);
-    }
-    
-    @Test
-    public void testSerialization2() throws IOException {
-        final AnsiCharSequence sequence = AnsiGenerator.make("Hello world!");
-        final AnsiAttr input = sequence.getAttrAt(3);
-        
-        AnsiAttr output = Serializer.copy(input);
-        
-        assertEquals(input, output);
-        
-        Serializer.SizeInfo sizeinfo = Serializer.sizeof(new VirtualList<AnsiAttr>() {
-            @Override
-            public int size() { return 100; }
-            @Override
-            public AnsiAttr get(int index) { return sequence.getAttrAt(index%sequence.length()); }
-        });
-        assertEquals(15, sizeinfo.self());
-        assertEquals(812, sizeinfo.attached());
-    }
-    
-    @Test
-    public void testAtFunctions() {
-        AnsiCharSequence text = new AnsiString("Hello world!");
-        text.setAttrAt(2, AnsiStrings.attr(3, 17, 8, AnsiAttr.BOLD));
-        
-        text.setAttrAt(3, AnsiStrings.attr(3, 17, 8, AnsiAttr.NARROW));
-        text.setAttrAt(3, AnsiStrings.attr(4, 18, 9));
-        
-        assertEquals(AnsiStrings.attr(3, 17, 8, AnsiAttr.BOLD), text.getAttrAt(2));
-        assertEquals(AnsiStrings.attr(4, 18, 9), text.getAttrAt(3));
-        
-        AnsiAttr a1 = AnsiStrings.attr(3, 17, 8, AnsiAttr.MASK_FLAGS_CLR | AnsiAttr.BOLD);
-        AnsiAttr a2 = AnsiStrings.attr(3, 17, 8, AnsiAttr.BOLD);
-        
-        
-        assertTrue(a1.equals(a2));
-        assertTrue(a1.equals(a2, AnsiAttr.CMP_FLAGS_ALL));
-        assertFalse(a1.equals(a2, AnsiAttr.CMP_IDENTICAL));
-        
-        text.setBackAt(5, 31);
-        text.setForeAt(5, 32);
-        text.setFontAt(5, 33);
-        text.setFlagsAt(5, AnsiAttr.BOLD | AnsiAttr.NO_NARROW);
-
-        assertFalse(AnsiStrings.attr("31 32 33 +b-n").equals(a2, AnsiAttr.CMP_ALL));
-    }
-    
-    @Test
-    public void testRegions() {
-        AnsiCharSequence text = new AnsiString("(Hello world!)");
-        
-        List<AnsiRegion> r1 = ListUtils.asList(text.regions(AnsiAttr.CMP_ALL));
-        assertEquals(1, r1.size());
-        assertEquals(AnsiStrings.attr(0,0,0), r1.get(0).attr());
-        assertEquals("(Hello world!)", r1.get(0).value().toString());
-
-        text.setAttr(1, 3, AnsiStrings.attr("4 17"));
-        text.setFont(2, 9, 8);
-        text.setFlags(7, 12, AnsiAttr.BOLD);
-
-        List<AnsiRegion> r2 = ListUtils.asList(text.regions(AnsiAttr.CMP_ALL));
-        assertEquals(7, r2.size());
-        assertEquals("(",    r2.get(0).value().toString());
-        assertEquals("H",    r2.get(1).value().toString());
-        assertEquals("e",    r2.get(2).value().toString());
-        assertEquals("llo ", r2.get(3).value().toString());
-        assertEquals("wo",   r2.get(4).value().toString());
-        assertEquals("rld",  r2.get(5).value().toString());
-        assertEquals("!)",   r2.get(6).value().toString());
-    }
-    
-    @Test
-    public void testSignConversion() {
-        AnsiCharSequence text =new AnsiString("Text");
-        text.setForeAt(0, 220);
-        text.setForeAt(1, 128);
-        text.setBackAt(0, 220);
-        text.setBackAt(1, 128);
-        text.setFontAt(0, 220);
-        text.setFontAt(1, 128);
-        
-        assertEquals(220, text.getForeAt(0));
-        assertEquals(128, text.getForeAt(1));
-        assertEquals(220, text.getBackAt(0));
-        assertEquals(128, text.getBackAt(1));
-        assertEquals(220, text.getFontAt(0));
-        assertEquals(128, text.getFontAt(1));
-    }
-}

+ 0 - 72
assira1/src/test/java/net/ranides/assira/text/format/AnsiStringsTest.java

@@ -1,72 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.text.format;
-
-import java.io.IOException;
-import net.ranides.assira.generic.Serializer;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-@SuppressWarnings("PMD")
-public class AnsiStringsTest {
-    
-    public AnsiStringsTest() {
-    }
-    
-    @Test
-    public void testString() {
-        AnsiAttr a1 = AnsiStrings.attr(4,5,19, AnsiAttr.BOLD);
-        assertEquals("AnsiAttr{4 5 19 +b}", a1.toString());
-        
-        AnsiAttr a2 = AnsiStrings.attr(4,5,19, AnsiAttr.MASK_FLAGS_SET);
-        AnsiAttr a3 = AnsiStrings.attr("AnsiAttr{4 5 19 +b +u +i +m +n +s +f +c}");
-        assertEquals(a2.toString(), a3.toString());
-    }
-
-    @Test
-    public void testValueOf() {
-        AnsiAttr a1 = AnsiStrings.attr(4,5,19, AnsiAttr.BOLD | AnsiAttr.NO_NARROW);
-        assertEquals(a1, AnsiStrings.attr("4 5 19 +b-n"));
-        assertEquals(a1, AnsiStrings.attr("4 5 19 +b -n"));
-        
-        AnsiAttr a2 = AnsiStrings.attr(4,5,19);
-        assertEquals(a2, AnsiStrings.attr("4 5 19"));
-        
-        AnsiAttr a3 = AnsiStrings.attr(4,5);
-        assertEquals(a3, AnsiStrings.attr("4 5"));
-        
-        AnsiAttr a4 = AnsiStrings.attr(4,5,19, AnsiAttr.MASK_FLAGS_SET);
-        AnsiAttr a5 = AnsiStrings.attr("AnsiAttr{4 5 19 +b +u +i +m +n +s +f +c}");
-        assertEquals(a4, a5);
-    }
-    
-    @Test
-    public void testSerialize() throws IOException {
-        AnsiAttr a1 = AnsiStrings.attr("4 5 19 +b-n");
-        AnsiAttr a2 = Serializer.copy(a1);
-        assertEquals(a1, a2);
-    }
-    
-    @Test
-    public void testEquals() {
-        AnsiAttr a1 = AnsiStrings.attr("4 5 19 +b +s -n");
-        AnsiAttr a2 = AnsiStrings.attr("4 5 19 +b +s -n");
-        AnsiAttr a3 = AnsiStrings.attr("7 6 20");
-        
-        assertTrue(a1.equals(a1));
-        assertTrue(a1.equals(a2));
-        
-        assertFalse(a1.equals(a3, AnsiAttr.CMP_BACK));
-        assertFalse(a1.equals(a3, AnsiAttr.CMP_FORE));
-        assertFalse(a1.equals(a3, AnsiAttr.CMP_FONT));
-    }
-    
-}