org.jsoup.UncheckedIOException Java Examples

The following examples show how to use org.jsoup.UncheckedIOException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CharacterReader.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void bufferUp() {
    if (bufPos < bufSplitPoint)
        return;

    try {
        readerPos += bufPos;
        reader.skip(bufPos);
        reader.mark(maxBufferLen);
        bufLength = reader.read(charBuf);
        reader.reset();
        bufPos = 0;
        bufMark = 0;
        bufSplitPoint = bufLength > readAheadLimit ? readAheadLimit : bufLength;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #2
Source File: CharacterReader.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void bufferUp() {
    if (bufPos < bufSplitPoint)
        return;

    try {
        readerPos += bufPos;
        reader.skip(bufPos);
        reader.mark(maxBufferLen);
        bufLength = reader.read(charBuf);
        reader.reset();
        bufPos = 0;
        bufMark = 0;
        bufSplitPoint = bufLength > readAheadLimit ? readAheadLimit : bufLength;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #3
Source File: ScreenshotTakerTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
private static BufferedImage loadImage()
{
    try
    {
        return ImageIO.read(ResourceUtils.loadFile(ScreenshotTakerTests.class, "screenshot.png"));
    }
    catch (IOException e)
    {
        throw new UncheckedIOException(e);
    }
}
 
Example #4
Source File: HttpConnection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void prepareByteData() {
    Validate.isTrue(executed, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
    if (byteData == null) {
        Validate.isFalse(inputStreamRead, "Request has already been read (with .parse())");
        try {
            byteData = DataUtil.readToByteBuffer(bodyStream, req.maxBodySize());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
}
 
Example #5
Source File: HttpConnection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void prepareByteData() {
    Validate.isTrue(executed, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
    if (byteData == null) {
        Validate.isFalse(inputStreamRead, "Request has already been read (with .parse())");
        try {
            byteData = DataUtil.readToByteBuffer(bodyStream, req.maxBodySize());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
}
 
Example #6
Source File: NpmTemplateParser.java    From flow with Apache License 2.0 4 votes vote down vote up
@Override
public TemplateData getTemplateContent(
        Class<? extends PolymerTemplate<?>> clazz, String tag,
        VaadinService service) {

    List<Dependency> dependencies = AnnotationReader
            .getAnnotationsFor(clazz, JsModule.class).stream()
            .map(jsModule -> new Dependency(Dependency.Type.JS_MODULE,
                    jsModule.value(),
                    LoadMode.EAGER)) // load mode doesn't matter here
            .collect(Collectors.toList());

    for (DependencyFilter filter : service.getDependencyFilters()) {
        dependencies = filter.filter(new ArrayList<>(dependencies),
                service);
    }

    Pair<Dependency, String> chosenDep = null;

    for (Dependency dependency : dependencies) {
        if (dependency.getType() != Dependency.Type.JS_MODULE) {
            continue;
        }

        String url = dependency.getUrl();
        String source = getSourcesFromTemplate(tag, url);
        if (source == null) {
            try {
                source = getSourcesFromStats(service, url);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
        if (source == null) {
            continue;
        }
        if (chosenDep == null) {
            chosenDep = new Pair<>(dependency, source);
        }
        if (dependencyHasTagName(dependency, tag)) {
            chosenDep = new Pair<>(dependency, source);
            break;
        }
    }

    if (chosenDep != null) {

        Element templateElement = BundleParser.parseTemplateElement(
                chosenDep.getFirst().getUrl(), chosenDep.getSecond());
        if (!JsoupUtils.getDomModule(templateElement, null).isPresent()) {
            // Template needs to be wrapped in an element with id, to look
            // like a P2 template
            Element parent = new Element(tag);
            parent.attr("id", tag);
            templateElement.appendTo(parent);
        }

        return new TemplateData(chosenDep.getFirst().getUrl(),
                templateElement);
    }

    throw new IllegalStateException(String.format("Couldn't find the "
            + "definition of the element with tag '%s' "
            + "in any template file declared using '@%s' annotations. "
            + "Check the availability of the template files in your WAR "
            + "file or provide alternative implementation of the "
            + "method getTemplateContent() which should return an element "
            + "representing the content of the template file", tag,
            JsModule.class.getSimpleName()));
}