Search in sources :

Example 6 with AtlasException

use of org.apache.jena.atlas.AtlasException in project jena by apache.

the class Timer method endTimer.

/** Return time in millisecods */
public long endTimer() {
    if (!inTimer)
        throw new AtlasException("Not in timer");
    timeFinish = System.currentTimeMillis();
    inTimer = false;
    return getTimeInterval();
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Example 7 with AtlasException

use of org.apache.jena.atlas.AtlasException in project jena by apache.

the class TupleMap method compileMapping.

/** Compile a mapping */
private static <T> int[] compileMapping(List<T> domain, List<T> range) {
    if (domain.size() != range.size())
        throw new AtlasException("Bad mapping: lengths not the same: " + domain + " -> " + range);
    int[] cols = new int[domain.size()];
    boolean[] mapped = new boolean[domain.size()];
    for (int i = 0; i < domain.size(); i++) {
        T input = domain.get(i);
        int j = range.indexOf(input);
        if (j < 0)
            throw new AtlasException("Bad mapping: missing mapping: " + domain + " -> " + range);
        if (mapped[j])
            throw new AtlasException("Bad mapping: duplicate: " + domain + " -> " + range);
        cols[i] = j;
        mapped[j] = true;
    }
    return cols;
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Example 8 with AtlasException

use of org.apache.jena.atlas.AtlasException in project jena by apache.

the class Hex method formatUnsignedLongHex.

// No checking, fixed width.
public static int formatUnsignedLongHex(final byte[] b, final int start, final long value, final int width) {
    // Insert from low value end to high value end.
    int idx = start + width - 1;
    int w = width;
    long x = value;
    while (w > 0) {
        int d = (int) (x & 0xF);
        // Unsigned shift.
        x = x >>> 4;
        byte ch = Bytes.hexDigitsUC[d];
        b[idx] = ch;
        w--;
        idx--;
        if (x == 0)
            break;
    }
    if (x != 0)
        throw new AtlasException("formatUnsignedLongHex: overflow");
    while (w > 0) {
        b[idx] = '0';
        idx--;
        w--;
    }
    return width;
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Example 9 with AtlasException

use of org.apache.jena.atlas.AtlasException in project jena by apache.

the class Timer method startTimer.

public void startTimer() {
    if (inTimer)
        throw new AtlasException("Already in timer");
    timeStart = System.currentTimeMillis();
    timeFinish = -1;
    inTimer = true;
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Example 10 with AtlasException

use of org.apache.jena.atlas.AtlasException in project jena by apache.

the class ColumnMap method compileMapping.

/** Compile a mapping */
static <T> int[] compileMapping(List<T> domain, List<T> range) {
    if (domain.size() != range.size())
        throw new AtlasException("Bad mapping: lengths not the same: " + domain + " -> " + range);
    int[] cols = new int[domain.size()];
    boolean[] mapped = new boolean[domain.size()];
    for (int i = 0; i < domain.size(); i++) {
        T input = domain.get(i);
        int j = range.indexOf(input);
        if (j < 0)
            throw new AtlasException("Bad mapping: missing mapping: " + domain + " -> " + range);
        if (mapped[j])
            throw new AtlasException("Bad mapping: duplicate: " + domain + " -> " + range);
        cols[i] = j;
        mapped[j] = true;
    }
    return cols;
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Aggregations

AtlasException (org.apache.jena.atlas.AtlasException)27 IOException (java.io.IOException)5 FileNotFoundException (java.io.FileNotFoundException)4 File (java.io.File)3 InputStream (java.io.InputStream)3 RiotParseException (org.apache.jena.riot.RiotParseException)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 Token (org.apache.jena.riot.tokens.Token)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Iterator (java.util.Iterator)1 InStreamUTF8 (org.apache.jena.atlas.io.InStreamUTF8)1 InputStreamBuffered (org.apache.jena.atlas.io.InputStreamBuffered)1 IteratorResourceClosing (org.apache.jena.atlas.iterator.IteratorResourceClosing)1 ProgressMonitor (org.apache.jena.atlas.lib.ProgressMonitor)1 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)1 FileSet (org.apache.jena.tdb.base.file.FileSet)1 Location (org.apache.jena.tdb.base.file.Location)1