Example usage for java.lang IllegalStateException IllegalStateException

List of usage examples for java.lang IllegalStateException IllegalStateException

Introduction

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

Prototype

public IllegalStateException(Throwable cause) 

Source Link

Document

Constructs a new exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.adito.webforwards.WebForwardDatabaseFactory.java

/**
 * @param webForwardDatabaseImpl the class of the webforward database 
 * @param lock weather to lock the policy database after setting it.
 * @throws IllegalStateException/*  w  w  w.  j  a v  a  2  s .  c o m*/
 */
public static void setFactoryImpl(Class webForwardDatabaseImpl, boolean lock) throws IllegalStateException {
    if (locked) {
        throw new IllegalStateException("WebForward database factory has been locked by another plugin.");
    }
    WebForwardDatabaseFactory.webForwardDatabaseImpl = webForwardDatabaseImpl;
    locked = lock;
}

From source file:com.sybase365.mobiliser.custom.project.businesslogic.configuration.CustomProjectConfiguration.java

@Override
public void afterPropertiesSet() {
    if (this.preferences == null) {
        throw new IllegalStateException("preferences not set in spring configuration.");
    }// www .  j a v a2  s  . c  o  m
}

From source file:net.mitnet.tools.pdf.book.io.FileNameSuffixFileFilter.java

public FileNameSuffixFileFilter(String fileSuffix) {
    if (fileSuffix == null) {
        throw new IllegalStateException("File suffix must be non-null");
    }//from  www . j a v a2 s  .  co  m
    if (fileSuffix.length() == 0) {
        throw new IllegalStateException("File suffix length must not be an empty String");
    }
    this.fileSuffix = fileSuffix;
}

From source file:org.hawkular.alerts.api.json.JsonUtil.java

public static <T> T fromJson(String json, Class<T> clazz, boolean thin) {
    try {/*from  w  w  w  .  j  av  a2s. c  o m*/
        return thin ? instance.mapperThin.readValue(json, clazz) : instance.mapper.readValue(json, clazz);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:Main.java

public static final void writeMalformedXml(Transformer transformer, OutputStream outputEntry, NodeList nodes) {
    Assert.notNull(transformer, "Transformer required");
    Assert.notNull(outputEntry, "Output entry required");
    Assert.notNull(nodes, "NodeList required");

    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

    try {/*from  w ww.  ja  v  a 2  s. c o  m*/
        for (int i = 0; i < nodes.getLength(); i++) {
            transformer.transform(new DOMSource(nodes.item(i)), createUnixStreamResultForEntry(outputEntry));
        }
    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}

From source file:co.rsk.peg.BridgeUtils.java

public static StoredBlock getStoredBlockAtHeight(BtcBlockStore blockStore, int height)
        throws BlockStoreException {
    StoredBlock storedBlock = blockStore.getChainHead();
    int headHeight = storedBlock.getHeight();
    if (height > headHeight) {
        return null;
    }// ww w.  j a  v  a  2s . c om
    for (int i = 0; i < (headHeight - height); i++) {
        if (storedBlock == null)
            return null;
        Sha256Hash prevBlockHash = storedBlock.getHeader().getPrevBlockHash();
        storedBlock = blockStore.get(prevBlockHash);
    }
    if (storedBlock != null) {
        if (storedBlock.getHeight() != height) {
            throw new IllegalStateException(
                    "Block height is " + storedBlock.getHeight() + " but should be " + headHeight);
        }
        return storedBlock;
    } else {
        return null;
    }
}

From source file:com.ixcode.framework.model.lookup.LookupContext.java

public Lookup getLookup(int id) {
    Integer key = new Integer(id);
    if (!_lookups.containsKey(key)) {
        throw new IllegalStateException("Could not find lookup for key '" + key + "' in lookup context");
    }/* w w w.java 2 s. c  o m*/
    return (Lookup) _lookups.get(key);
}

From source file:Main.java

public static String unescapeXML(String str) {
    if (str == null || str.length() == 0)
        return str;
    final StringBuilder buf = new StringBuilder(255);
    final int len = str.length();
    for (int i = 0; i < len; ++i) {
        final char c = str.charAt(i);
        if (c == '&') {
            final int pos = str.indexOf(';', i);
            if (pos == -1) {
                buf.append('&');
            } else if (str.charAt(i + 1) == '#') { // &#unicode;
                final int val = Integer.parseInt(str.substring(i + 2, pos), 16);
                buf.append((char) val); // '&#xD;' -> '\r'
                i = pos;/*from  w ww  . jav a 2 s.c  o m*/
            } else {
                final String substr = str.substring(i, pos + 1);
                if (substr.equals("&amp;")) {
                    buf.append('&');
                } else if (substr.equals("&lt;")) {
                    buf.append('<');
                } else if (substr.equals("&gt;")) {
                    buf.append('>');
                } else if (substr.equals("&quot;")) {
                    buf.append('"');
                } else if (substr.equals("&apos;")) {
                    buf.append('\'');
                } else {
                    throw new IllegalStateException(
                            "Invalid XML charactor `" + substr + "` is detected at " + i + " of " + str + '!');
                }
                i = pos;
            }
        } else {
            buf.append(c);
        }
    }
    return buf.toString();
}

From source file:org.jspringbot.keyword.expression.engine.function.StaticMethodUtils.java

public static Method getMethod(Class clazz, String methodSignature) {
    Matcher matcher = METHOD_SIGNATURE_PATTERN.matcher(methodSignature);

    if (matcher.find()) {
        String methodName = matcher.group(2);
        String parameterTypes = matcher.group(3);

        List<Class> types = new ArrayList<Class>();
        for (String parameterType : StringUtils.split(parameterTypes, ',')) {
            ClassEditor editor = new ClassEditor();
            editor.setAsText(parameterType);
            types.add((Class) editor.getValue());
        }//from  w w w  .  j  a v  a  2  s. c o m

        return MethodUtils.getAccessibleMethod(clazz, methodName, types.toArray(new Class[types.size()]));
    }

    throw new IllegalStateException(String.format("Invalid method signature '%s' found.", methodSignature));
}

From source file:com.qcadoo.mes.masterOrders.constants.MasterOrderType.java

public static MasterOrderType parseString(final String rawMasterOrderType) {
    if (StringUtils.isBlank(rawMasterOrderType)) {
        return UNDEFINED;
    }/*  w w  w. ja  va2s.c  om*/

    String masterOrderType = StringUtils.trim(rawMasterOrderType);
    for (MasterOrderType type : values()) {
        if (StringUtils.equalsIgnoreCase(type.getStringValue(), masterOrderType)) {
            return type;
        }
    }

    throw new IllegalStateException("Unsupported masterOrderType: " + masterOrderType);
}