Example usage for java.lang NoSuchMethodException NoSuchMethodException

List of usage examples for java.lang NoSuchMethodException NoSuchMethodException

Introduction

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

Prototype

public NoSuchMethodException() 

Source Link

Document

Constructs a NoSuchMethodException without a detail message.

Usage

From source file:org.docx4j.model.datastorage.OpenDoPEHandler.java

private WordprocessingMLPackage fetchComponents(WordprocessingMLPackage srcPackage,
        ContentAccessor contentAccessor) throws Docx4JException {

    // convert components to altChunk
    Map<Integer, CTAltChunk> replacements = new HashMap<Integer, CTAltChunk>();
    Integer index = 0;// w w w  .  j  a  v  a2 s  . c  o m
    justGotAComponent = false;

    LinkedList<Integer> continuousBeforeIndex = new LinkedList<Integer>();
    List<Boolean> continuousBefore = new ArrayList<Boolean>();

    List<Boolean> continuousAfter = new ArrayList<Boolean>();

    for (Object block : contentAccessor.getContent()) {

        // Object ublock = XmlUtils.unwrap(block);
        if (block instanceof org.docx4j.wml.SdtBlock) {

            org.docx4j.wml.SdtBlock sdt = (org.docx4j.wml.SdtBlock) block;

            Tag tag = getSdtPr(sdt).getTag();

            if (tag == null) {
                List<Object> newContent = new ArrayList<Object>();
                newContent.add(sdt);
                continue;
            }

            log.info(tag.getVal());

            HashMap<String, String> map = QueryString.parseQueryString(tag.getVal(), true);

            String componentId = map.get(BINDING_ROLE_COMPONENT);
            if (componentId == null)
                continue;

            // Convert the sdt to a w:altChunk
            // .. get the IRI
            String iri = ComponentsPart.getComponentById(components, componentId).getIri();
            log.debug("Fetching " + iri);

            if (docxFetcher == null) {
                log.error("You need a docxFetcher (and the MergeDocx extension) to fetch components");
                return srcPackage;
            }

            // .. create the part
            AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(
                    getNewPartName("/chunk", ".docx", srcPackage.getMainDocumentPart().getRelationshipsPart()));
            afiPart.setBinaryData(docxFetcher.getDocxFromIRI(iri));

            afiPart.setContentType(new ContentType(
                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")); // docx

            Relationship altChunkRel = srcPackage.getMainDocumentPart().addTargetPart(afiPart);
            CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
            ac.setId(altChunkRel.getId());

            replacements.put(index, ac);

            /*
             * 2011 12 11 TODO.  Rethink support for
             * od:continuousBefore and od:continuousAfter.
             */

            // This is handled in this class
            if (map.get(BINDING_ROLE_COMPONENT_BEFORE) != null
                    && map.get(BINDING_ROLE_COMPONENT_BEFORE).equals("true")) {
                continuousBefore.add(Boolean.TRUE);
                continuousBeforeIndex.addFirst(index);
                log.info("ctsBefore index: " + index);
            } else {
                continuousBefore.add(Boolean.FALSE);
                continuousBeforeIndex.addFirst(index);
            }

            // The following is handled in ProcessAltChunk
            if (map.get(BINDING_ROLE_COMPONENT_AFTER) != null
                    && map.get(BINDING_ROLE_COMPONENT_AFTER).equals("true")) {
                continuousAfter.add(Boolean.TRUE);
            } else {
                continuousAfter.add(Boolean.TRUE);
            }

            justGotAComponent = true;
        }
        index++;
    }

    if (!justGotAComponent) {
        return srcPackage;
    }

    // Now replace in list
    for (Integer key : replacements.keySet()) {
        contentAccessor.getContent().set(key, replacements.get(key));
    }

    // Go through docx in reverse order
    List<Object> bodyChildren = contentAccessor.getContent();
    int i = 0;
    for (Integer indexIntoBody : continuousBeforeIndex) {

        if (continuousBefore.get(i)) {
            // Element before the w:altChunk
            if (indexIntoBody == 0) {
                // // Insert a sectPr right at the beginning of the docx?
                // // TODO check this isn't necessary
                // SectPr newSectPr =
                // Context.getWmlObjectFactory().createSectPr();
                // SectPr.Type type =
                // Context.getWmlObjectFactory().createSectPrType();
                // type.setVal("continuous");
                // newSectPr.setType( type );
                //
                // bodyChildren.add(0, newSectPr);

            } else {
                Object block = bodyChildren.get(indexIntoBody.intValue() - 1);
                if (block instanceof P && ((P) block).getPPr() != null
                        && ((P) block).getPPr().getSectPr() != null) {
                    makeContinuous(((P) block).getPPr().getSectPr());
                } else if (block instanceof P) {
                    // More likely
                    PPr ppr = ((P) block).getPPr();
                    if (ppr == null) {
                        ppr = Context.getWmlObjectFactory().createPPr();
                        ((P) block).setPPr(ppr);
                    }
                    SectPr newSectPr = Context.getWmlObjectFactory().createSectPr();
                    SectPr.Type type = Context.getWmlObjectFactory().createSectPrType();
                    type.setVal("continuous");
                    newSectPr.setType(type);

                    ppr.setSectPr(newSectPr);
                } else {
                    // Equally likely - its a table or something, so add a p
                    P newP = Context.getWmlObjectFactory().createP();
                    PPr ppr = Context.getWmlObjectFactory().createPPr();
                    newP.setPPr(ppr);

                    SectPr newSectPr = Context.getWmlObjectFactory().createSectPr();
                    SectPr.Type type = Context.getWmlObjectFactory().createSectPrType();
                    type.setVal("continuous");
                    newSectPr.setType(type);
                    ppr.setSectPr(newSectPr);

                    bodyChildren.add(indexIntoBody.intValue(), newP); // add
                    // before
                    // altChunk
                }
            }
        }
        // else nothing specified, so go with normal MergeDocx behaviour

        i++;
    }

    // process altChunk
    try {
        // Use reflection, so docx4j can be built
        // by users who don't have the MergeDocx utility
        Class<?> documentBuilder = Class.forName("com.plutext.merge.ProcessAltChunk");
        // Method method = documentBuilder.getMethod("merge",
        // wmlPkgList.getClass());
        Method[] methods = documentBuilder.getMethods();
        Method processMethod = null;
        for (int j = 0; j < methods.length; j++) {
            log.debug(methods[j].getName());
            if (methods[j].getName().equals("process")) {
                processMethod = methods[j];
            }
        }
        if (processMethod == null)
            throw new NoSuchMethodException();
        return (WordprocessingMLPackage) processMethod.invoke(null, srcPackage);

    } catch (ClassNotFoundException e) {
        extensionMissing(e);
        justGotAComponent = false;
        return srcPackage;
        // throw new Docx4JException("Problem processing w:altChunk", e);
    } catch (NoSuchMethodException e) {
        // Degrade gracefully
        extensionMissing(e);
        justGotAComponent = false;
        return srcPackage;
        // throw new Docx4JException("Problem processing w:altChunk", e);
    } catch (Exception e) {
        throw new Docx4JException("Problem processing w:altChunk", e);
    }
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest06.java

/**
 * testValidateArraysIndex07()//from  www .  j  a v a  2  s  .  co m
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FC,F
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6S??<br>
 *                name?F"testArray"<br>
 *         (?) field:not null<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *         (?) session:not null<br>
 *         (?) ActionForm:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?FG?[<br>
 *                    ONX?F<br>
 *                    NoSuchMethodException<br>
 *                    ?Ox?FG?[<br>
 *                    ?bZ?[W?F<br>
 *                    "Can not get validateMethod."<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * vaname?\bhFieldChecksEx?A
 * ValidWhen????AtruemF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateArraysIndex07() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams(this.validClassStr);
    va.setName("testArray");

    // ++++ ?tB?[h?
    Field field = new Field();

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    HttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());

    // G?[?O`FbN
    assertTrue(LogUTUtil.checkError("", new NoSuchMethodException()));
    assertTrue(LogUTUtil.checkError("Can not get validateMethod."));
}

From source file:info.papdt.blacklight.support.Utility.java

public static Method findMethod(Class<?> clazz, String name) throws NoSuchMethodException {
    Class<?> cla = clazz;/*from  www .  ja v a  2  s  . c o  m*/
    Method method = null;

    do {
        try {
            method = cla.getDeclaredMethod(name);
        } catch (NoSuchMethodException e) {
            method = null;
            cla = cla.getSuperclass();
        }
    } while (method == null && cla != Object.class);

    if (method == null) {
        throw new NoSuchMethodException();
    } else {
        return method;
    }
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest06.java

/**
 * testValidateArraysIndex08()/*from  w  ww . j  a  v a2s  .  c  o  m*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F"java.lang.String"<br>
 *                name?F"stringLengthArray"<br>
 *         (?) field:not null<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *         (?) session:not null<br>
 *         (?) ActionForm:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?FG?[<br>
 *                    ONX?F<br>
 *                    NoSuchMethodException<br>
 *                    ?Ox?FG?[<br>
 *                    ?bZ?[W?F<br>
 *                    "Can not get validateMethod."<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * va?`FbN?\bh??A
 * methodParamsw?v???A
 * truemF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateArraysIndex08() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams("java.lang.String");
    va.setName("stringLengthArray");

    // ++++ ?tB?[h?
    Field field = new Field();

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    HttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());

    // G?[?O`FbN
    assertTrue(LogUTUtil.checkError("", new NoSuchMethodException()));
    assertTrue(LogUTUtil.checkError("Can not get validateMethod."));
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest06.java

/**
 * testValidateArraysIndex09()/*  w w w .j av a  2s.  c  o m*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?F6??<br>
 *                name?F"stringLengthArray"<br>
 *         (?) field:not null<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *         (?) session:not null<br>
 *         (?) ActionForm:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?FG?[<br>
 *                    ONX?F<br>
 *                    NoSuchMethodException<br>
 *                    ?Ox?FG?[<br>
 *                    ?bZ?[W?F<br>
 *                    "Can not get validateMethod."<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * va?`FbN?\bh??A
 * methodParamsw?v???A
 * truemF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateArraysIndex09() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    String argStr = "javax.servlet.http.HttpServletRequest," + "org.apache.commons.validator.ValidatorAction,"
            + "org.apache.commons.validator.Field," + "org.apache.struts.action.ActionMessages,"
            + "org.apache.commons.validator.Validator," + "java.lang.Object";
    va.setMethodParams(argStr);
    va.setName("stringLengthArray");

    // ++++ ?tB?[h?
    Field field = new Field();

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    HttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());

    // G?[?O`FbN
    assertTrue(LogUTUtil.checkError("", new NoSuchMethodException()));
    assertTrue(LogUTUtil.checkError("Can not get validateMethod."));
}