Example usage for java.lang InternalError InternalError

List of usage examples for java.lang InternalError InternalError

Introduction

In this page you can find the example usage for java.lang InternalError InternalError.

Prototype

public InternalError(Throwable cause) 

Source Link

Document

Constructs an InternalError with the specified cause and a detail message of (cause==null ?

Usage

From source file:gdv.xport.feld.Feld.java

/**
 * Ermittelt die FeldInfo aus dem uebergebenen Enum.
 *
 * @param feldX the feld x//w w  w.jav  a 2  s.c o m
 * @return the feld info
 */
protected static FeldInfo getFeldInfo(final Enum<?> feldX) {
    try {
        Field field = feldX.getClass().getField(feldX.name());
        return field.getAnnotation(FeldInfo.class);
    } catch (NoSuchFieldException nsfe) {
        throw new InternalError("no field " + feldX + " (" + nsfe + ")");
    }
}

From source file:com.manydesigns.portofino.persistence.QueryUtils.java

protected static String processTextMatchMode(TextMatchMode textMatchMode, String value) {
    String pattern;/*from w  w w  . jav a 2 s .  c  o  m*/
    switch (textMatchMode) {
    case EQUALS:
        pattern = value;
        break;
    case CONTAINS:
        pattern = "%" + value + "%";
        break;
    case STARTS_WITH:
        pattern = value + "%";
        break;
    case ENDS_WITH:
        pattern = "%" + value;
        break;
    default:
        String msg = MessageFormat.format("Unrecognized text match mode: {0}", textMatchMode);
        logger.error(msg);
        throw new InternalError(msg);
    }
    return pattern;
}

From source file:net.sf.firemox.tools.MToolKit.java

/**
 * Write the specified positive integer coded on 3 bytes to the specified
 * input stream/*from  w  ww .  j  a  va2s.  c  o  m*/
 * 
 * @param out
 *          is the output stream where the specified integer would be written
 * @param int24
 *          the 3 bytes integer to write
 */
public static void writeInt24(OutputStream out, int int24) {
    try {
        out.write(int24 / 65536);
        out.write(int24 % 65536 / 256);
        out.write(int24 % 256);
    } catch (Exception e) {
        throw new InternalError("writing int24 in file," + e);
    }
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.LongDataset.java

@SuppressWarnings({ "unchecked" })
@Override/*from   w w  w  .j  a v a 2 s.co m*/
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().longValue()); // PRIM_TYPE
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.ByteDataset.java

@SuppressWarnings({ "unchecked" })
@Override/*  www .  j  ava2  s .co m*/
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().byteValue()); // PRIM_TYPE
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.IntegerDataset.java

@SuppressWarnings({ "unchecked" })
@Override//w w w  .  java 2s.c o m
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().intValue()); // PRIM_TYPE
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.ShortDataset.java

@SuppressWarnings({ "unchecked" })
@Override/*www.j av a2 s  .c  o  m*/
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().shortValue()); // PRIM_TYPE
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.FloatDataset.java

@SuppressWarnings({ "unchecked" })
@Override//from www.  ja  v a  2 s. co m
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().floatValue()); // PRIM_TYPE
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}

From source file:com.puppycrawl.tools.checkstyle.CheckerTest.java

@Test
public void testCatchErrorInProcessFilesMethod() throws Exception {
    // The idea of the test is to satisfy coverage rate.
    // An Error indicates serious problems that a reasonable application should not try to
    // catch, but due to issue https://github.com/checkstyle/checkstyle/issues/2285
    // we catch errors in 'processFiles' method. Most such errors are abnormal conditions,
    // that is why we use PowerMockito to reproduse them.
    final File mock = PowerMockito.mock(File.class);
    // Assume that I/O error is happened when we try to invoke 'lastModified()' method.
    final String errorMessage = "Java Virtual Machine is broken"
            + " or has run out of resources necessary for it to continue operating.";
    final Error expectedError = new IOError(new InternalError(errorMessage));
    when(mock.lastModified()).thenThrow(expectedError);
    final Checker checker = new Checker();
    final List<File> filesToProcess = Lists.newArrayList();
    filesToProcess.add(mock);/*from   w  w w .j  a  v  a  2s  .c om*/
    try {
        checker.process(filesToProcess);
        fail("IOError is expected!");
    } catch (Error error) {
        assertThat(error.getCause(), instanceOf(IOError.class));
        assertThat(error.getCause().getCause(), instanceOf(InternalError.class));
        assertEquals(errorMessage, error.getCause().getCause().getMessage());
    }
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.DoubleDataset.java

@SuppressWarnings({ "unchecked" })
@Override//www.jav  a 2 s. c om
public int[] maxPos() {
    if (storedValues == null) {
        calculateMaxMin();
    }
    Object o = storedValues.get("maxpos");
    List<Integer> max = null;
    if (o == null) {
        max = findPositions(max().doubleValue()); // PRIM_TYPE // BOOLEAN_OMIT
        // max = findPositions(max().intValue() != 0); // BOOLEAN_USE
        // max = findPositions(null); // OBJECT_USE
        storedValues.put("maxpos", max);
    } else if (o instanceof List<?>) {
        max = (ArrayList<Integer>) o;
    } else {
        throw new InternalError("Inconsistent internal state of stored values for statistics calculation");
    }

    return getNDPosition(max.get(0)); // first maximum
}