/*
 * Copyright (c) 2014 Mozilla Foundation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

package org.whattf.datatype;

import java.util.List;

import org.relaxng.datatype.DatatypeException;

public class SourceSizeList extends AbstractDatatype {

    /**
     * The singleton instance.
     */
    public static final SourceSizeList THE_INSTANCE = new SourceSizeList();

    protected SourceSizeList() {
        super();
    }

    @Override public void checkValid(CharSequence literal)
            throws DatatypeException {
        for (CharSequenceWithOffset unparsedSize : split(literal, ',')) {
        }
    }

    @Override public String getName() {
        return "source size list";
    }

}

@@ -1151,32 +1151,8 @@
 e;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -1194,16 +1194,16 @@
 eption;%0A
+
 %0Apublic 
@@ -1542,73 +1542,1184 @@
     
-for (CharSequenceWithOffset unparsedSize : split(literal, ',')) %7B
+int offset = 0;%0A        StringBuilder unparsedSize = new StringBuilder();%0A        StringBuilder extract = new StringBuilder();%0A        for (int i = 0; i %3C literal.length(); i++) %7B%0A            char c = literal.charAt(i);%0A            extract.append(c);%0A            if (',' == c) %7B%0A                unparsedSize.append(literal.subSequence(offset, i));%0A                checkSize(unparsedSize, extract);%0A                unparsedSize.setLength(0);%0A                offset = i + 1;%0A            %7D%0A        %7D%0A        unparsedSize.append(literal.subSequence(offset, literal.length()));%0A        checkSize(unparsedSize, extract);%0A    %7D%0A%0A    private void checkSize(StringBuilder unparsedSize, StringBuilder extract) %7B%0A        trimTrailingWhitespace(unparsedSize);%0A        if (unparsedSize.length() == 0) %7B%0A            // error empty%0A            return;%0A        %7D%0A    %7D%0A%0A    private void trimTrailingWhitespace(StringBuilder sb) %7B%0A        for (int i = sb.length(); i %3E 0; i--) %7B%0A            char c = sb.charAt(i - 1);%0A            if (' ' == c %7C%7C '%5Ct' == c %7C%7C '%5Cn' == c %7C%7C '%5Cf' == c %7C%7C '%5Cr' == c) %7B%0A                sb.setLength(i - 1);%0A            %7D else %7B%0A                return;%0A            %7D
 %0A   

Implement @sizes splitting & trimming of each size