Example usage for java.lang Module Module

List of usage examples for java.lang Module Module

Introduction

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

Prototype

Module(ClassLoader loader) 

Source Link

Document

Create the unnamed Module for the given ClassLoader.

Usage

From source file:org.op4j.functions.FnInteger.java

/**
 * <p>/*  w w w.j ava2  s . c o m*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Integer, Integer> module(Short module) {
    return new Module(BigInteger.valueOf(module.longValue()));
}

From source file:org.op4j.functions.FnLong.java

/**
 * <p>/*w  w w  . j  a v  a  2  s. c om*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Long, Long> module(Long module) {
    return new Module(BigInteger.valueOf(module.longValue()));
}

From source file:org.op4j.functions.FnShort.java

/**
 * <p>//from ww  w  .j  a v a2 s . co m
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Short, Short> module(Long module) {
    return new Module(BigInteger.valueOf(module.longValue()));
}

From source file:org.op4j.functions.FnInteger.java

/**
 * <p>/*w  w  w  . ja v a 2 s .  com*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Integer, Integer> module(Integer module) {
    return new Module(BigInteger.valueOf(module.longValue()));
}

From source file:org.op4j.functions.FnLong.java

/**
 * <p>/*from   w  w w  .  j  ava  2s .  c  o m*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Long, Long> module(BigInteger module) {
    return new Module(module);
}

From source file:org.op4j.functions.FnShort.java

/**
 * <p>/*from   w  w w .j  av  a 2  s.c om*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Short, Short> module(BigInteger module) {
    return new Module(module);
}

From source file:org.op4j.functions.FnInteger.java

/**
 * <p>/*from   ww w . java  2  s.c  o  m*/
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Integer, Integer> module(Long module) {
    return new Module(BigInteger.valueOf(module.longValue()));
}

From source file:org.op4j.functions.FnInteger.java

/**
 * <p>//from  w  w  w  . j  a  v  a2s  .  c om
 * It performs a module operation and returns the value
 * of (input mod module) which is always positive 
 * (whereas remainder is not)
 * </p>
 * 
 * @param module the module
 * @return the result of (input mod module)
 */
public final static Function<Integer, Integer> module(BigInteger module) {
    return new Module(module);
}

From source file:org.etudes.component.app.melete.ModuleDB.java

public void copyModule(Module module, String courseId, String userId) throws MeleteException {
    ResourceLoader bundle = new ResourceLoader("melete_license");

    try {/*  w  w  w  . j  a v  a 2  s . c  o m*/
        //get module and its sections
        Module copyMod = new Module(module);
        String firstName = UserDirectoryService.getCurrentUser().getFirstName();
        String lastName = UserDirectoryService.getCurrentUser().getLastName();

        DateFormat shortTime = DateFormat.getDateInstance(DateFormat.LONG);

        copyMod.setCreatedByFname(firstName);
        copyMod.setCreatedByLname(lastName);
        copyMod.setTitle(copyMod.getTitle() + " (" + bundle.getString("Copied") + " "
                + shortTime.format(new Date()) + " )");
        ModuleShdates CopyModuleshowdates = new ModuleShdates((ModuleShdates) module.getModuleshdate());

        // insert copy module with blank seq_xml and sections as null
        addModule(copyMod, CopyModuleshowdates, userId, courseId);

        String copyModSeqXml = module.getSeqXml();
        //get sections
        List<Section> toCopySections = getSections(module.getModuleId().intValue());
        if (toCopySections != null && toCopySections.size() > 0) {
            for (Section toCopySection : toCopySections) {
                // with title as copy of xxx and sectionResource
                Section copySection = new Section(toCopySection);
                copySection.setCreatedByFname(firstName);
                copySection.setCreatedByLname(lastName);
                copySection.setModule(copyMod);
                copySection.setTitle(copySection.getTitle() + " (" + bundle.getString("Copied") + " "
                        + shortTime.format(new Date()) + " )");
                //insert section
                Integer copySectionId = sectionDB.addSection(copyMod, copySection, false);
                copySection.setSectionId(copySectionId);
                //copySection.setModule(copyMod);
                if (toCopySection.getContentType() != null
                        && !toCopySection.getContentType().equals("notype")) {
                    // if section content type is composed than create a new copy
                    if (toCopySection.getContentType().equals("typeEditor")) {

                        String copyModCollId = meleteCHService.getCollectionId("typeEditor",
                                copyMod.getModuleId());
                        String res_mime_type = meleteCHService.MIME_TYPE_EDITOR;
                        ContentResource cr = meleteCHService
                                .getResource(toCopySection.getSectionResource().getResource().getResourceId());
                        byte[] secContentData = cr.getContent();

                        boolean encodingFlag = true;
                        String secResourceName = meleteCHService.getTypeEditorSectionName(copySectionId);
                        String secResourceDescription = "compose content";

                        ResourcePropertiesEdit res = meleteCHService.fillInSectionResourceProperties(
                                encodingFlag, secResourceName, secResourceDescription);
                        String newResourceId = meleteCHService.addResourceItem(secResourceName, res_mime_type,
                                copyModCollId, secContentData, res);

                        MeleteResource copyMelResource = new MeleteResource(
                                (MeleteResource) toCopySection.getSectionResource().getResource());
                        copyMelResource.setResourceId(newResourceId);
                        sectionDB.insertMeleteResource(copySection, copyMelResource);
                    } else if (toCopySection.getSectionResource() != null) {
                        // insert section resource with same melete resource
                        MeleteResource copyMr = (MeleteResource) toCopySection.getSectionResource()
                                .getResource();
                        if (copyMr != null)
                            sectionDB.insertSectionResource(copySection, copyMr);
                    }
                }
                // replace with new copied section
                copyModSeqXml = copyModSeqXml.replace(toCopySection.getSectionId().toString(),
                        copySectionId.toString());
            }
        }
        // update module seq xml
        Module copyMod1 = getModule(copyMod.getModuleId());
        copyMod1.setSeqXml(copyModSeqXml);
        updateModule(copyMod1);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new MeleteException("copy_fail");
    }
}