Package org.luaj.vm2.lib

Examples of org.luaj.vm2.lib.IoLib$File


        List<AtomicItem> list = new ArrayList<AtomicItem>(divs.length);
        for (int index = 0; index < divs.length; index++) {
            Div d = divs[index];
            if ("page".equals(d.getTYPE())) {
                Fptr fptr = d.getFptr(0);
                File file = (File) fptr.getFILEID();
                String groupId = file.getGROUPID();
                int size = list.size();
                if (size == 0 || (size > 0 && !(groupId.equals(list.get(size - 1).getId())))) {
                    AtomicItem item = parsePage(d);
                    item.setId(groupId);
                    list.add(item);
View Full Code Here


                    if (dataStream != null) {
                        Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                        for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                            Map<String, String> stream = new HashMap<String, String>();
                            for (Fptr fptr2: fptrs) {
                                File file = (File)fptr2.getFILEID();
                                String use = file.getUSE();
                                if (entry.getValue().get(use) != null) {
                                    stream.put(use, file.getFLocat(0).getHref());
                                }
                            }
                            metsObj.getDataStreamsMap().put(entry.getKey(), stream);
                        }
                    }                   
                }
            }

            // Now we can process logicalStruct
            for (int i = 0; i < maps.length; i++) {
                StructMap structMap = maps[i];
                Div div = structMap.getDiv();
                String type = structMap.getTYPE();
                if (MetsConstants.LOGICAL.equals(type)) {
                    Map<String, CompositeItem> cimap = new HashMap<String, CompositeItem>();               
                    metsObj.setCompositeItemMap(cimap);
                    metsObj.setDescription(div.getLABEL());
                   
                    Fptr[] fptrs = div.getFptr();
                    ParameterMap dataStream = config.getDataStream();
                    if (dataStream != null) {
                        Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                        for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                            Map<String, String> stream = new HashMap<String, String>();
                            for (Fptr fptr2: fptrs) {
                                File file = (File)fptr2.getFILEID();
                                String use = file.getUSE();
                                if (entry.getValue().get(use) != null) {
                                    stream.put(use, file.getFLocat(0).getHref());
                                }
                            }
                            metsObj.getDataStreamsMap().put(entry.getKey(), stream);
                        }
                    }
View Full Code Here

    protected Object parseLogicalStruct(String oid, Div div, CompositeItem parent)
            throws DAOException {
        if ("page".equals(div.getTYPE()) || div.getDivCount() == 0) {
            if (div.getFptrCount() > 0) {
                Fptr fptr = div.getFptr(0);
                File file = (File) fptr.getFILEID();
                String groupId = file.getGROUPID();
                AtomicItem item = metsObj.getAtomicItemByID(groupId);
                item.setParent(parent);
                return item;
            } else if (div.getMptrCount() > 0) {
                Mptr mptr = div.getMptr(0);
                MetsPointerAtomicItem item = new MetsPointerAtomicItem();
                item.setType(div.getTYPE());
                item.setLabel(div.getLABEL());
                item.setParent(parent);
                item.setHref(mptr.getHref());
                return item;
            } else {
                return null;
            }
        } else {
            String type = div.getTYPE();
            String label = div.getLABEL();
            CompositeItem division = new CompositeItem();
            division.setType(type);
            division.setLabel(label);
            if (div.getCONTENTIDSCount() > 0) {
              division.setContentId(div.getCONTENTIDS(0));
            }
            if (StringUtils.isBlank(div.getID())) {
                division.setId(generateUniqueID());
            } else {
                division.setId(div.getID());
            }
            metsObj.getCompositeItemMap().put(division.getId(), division);
            if (div.getDMDIDCount() == 1) {
                DmdSec dmd = (DmdSec) div.getDMDID(0);
                division.setDmdID(dmd.getID());
            }

            Div[] divs = div.getDiv();
            division.setChildren(new ArrayList<AbstractItem>(divs.length));
            for (int i = 0; i < divs.length; i++) {
                Div d = divs[i];
                Object obj = parseLogicalStruct(oid, d, division);
                if (obj instanceof AtomicItem) {
                    // Add page to division's child list
                    division.addChild((AtomicItem) obj);
                    if (i == 0) {
                        division.setFirst((AtomicItem) obj);
                    }
                    if (i == divs.length - 1) {
                        division.setLast((AtomicItem) obj);
                    }
                } else if (obj instanceof CompositeItem) {
                    division.addChild((CompositeItem) obj);
                    if (i == 0) {
                        division.setFirst(((CompositeItem) obj).getFirst());
                    }
                    if (i == divs.length - 1) {
                        division.setLast(((CompositeItem) obj).getLast());
                    }
                }
            }

            Fptr[] fptrs = div.getFptr();
            ParameterMap dataStream = config.getDataStream();
            if (dataStream != null) {
                Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                    Map<String, String> stream = new HashMap<String, String>();
                    for (Fptr fptr2: fptrs) {
                        File file = (File)fptr2.getFILEID();
                        String use = file.getUSE();
                        if (entry.getValue().get(use) != null) {
                            stream.put(use, file.getFLocat(0).getHref());
                        }
                    }
                    division.getDataStreamsMap().put(entry.getKey(), stream);
                }
            }
View Full Code Here

import java.io.IOException;

public class ModuleExecutor {
    public String run(IWikiModel model, String module, String method, Frame frame) throws IOException {
        final Globals globals = getGlobals();
        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }
View Full Code Here

        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }

    private Globals getGlobals() {
        final Globals globals = JsePlatform.standardGlobals();
//        LuaJC.install(globals);
        return globals;
    }
View Full Code Here

                    defaultAnimationName = animationName; // set first animation as the default one
                }
            }
            catch (SpriteException ex) {
                // Error in the input file.
                throw new LuaError(ex);
            }
            catch (Exception ex) {
                // Error in the editor.
                ex.printStackTrace();
                throw new LuaError(ex);
            }

            return LuaValue.NIL;
        }
View Full Code Here

            LuaC.install();
            LuaTable environment = LuaValue.tableOf();

            environment.set("animation", new AnimationFunction());

            LuaFunction code = LoadState.load(new FileInputStream(spriteFile),
                spriteFile.getName(), environment);
            code.call();
        }
        catch (IOException ex) {
            throw new SpriteException(ex.getMessage());
        }
        catch (LuaError ex) {
View Full Code Here

                    if (!param.get("raw").isnil()) {
                        actualParam = param.get("raw").checkjstring();
                    } else if (!param.get("num").isnil()) {
                        if (param.get("num").isnumber()) {
                            LuaNumber number = param.get("num").checknumber();
                            NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang));
                            actualParam = nf.format(number.todouble());
                        } else {
                            actualParam = param.get("num").tojstring();
                        }
                    } else {
                        actualParam = "unknown";
View Full Code Here

        try {
            this.animations = new TreeMap<String, SpriteAnimation>();
            File spriteFile = Project.getSpriteFile(animationSetId);
            LuaC.install();
            LuaTable environment = LuaValue.tableOf();

            environment.set("animation", new AnimationFunction());

            LuaFunction code = LoadState.load(new FileInputStream(spriteFile),
                spriteFile.getName(), environment);
            code.call();
        }
View Full Code Here

        @Override
        public LuaValue call(LuaValue arg) {

            try {
                LuaTable table = arg.checktable();

                String animationName = table.get("name").checkjstring();
                String srcImageName = table.get("src_image").checkjstring();
                int frameDelay = table.get("frame_delay").optint(0);
                int frameToLoopOn = table.get("frame_to_loop_on").optint(-1);
                LuaTable directionsTable = table.get("directions").checktable();

                BufferedImage srcImage = null;

                try {
                    if (!srcImageName.equals("tileset")) {
                        srcImage = Project.getProjectImage("sprites/" + srcImageName);
                    }
                    else if (!tilesetId.isEmpty()) {
                        srcImage = Project.getProjectImage(
                                "tilesets/" + Project.getTilesetEntitiesImageFile(tilesetId).getName());
                    }
                } catch (IOException ex) {
                    // image cannot be loaded
                }

                Vector<SpriteAnimationDirection> directions = new Vector<SpriteAnimationDirection>();

                // Traverse the directions table.
                LuaValue key = LuaValue.NIL;
                while (true) {

                    Varargs keyValue = directionsTable.next(key);
                    key = keyValue.arg1();
                    if (key.isnil()) {
                        break;
                    }
                    LuaValue directionTable = keyValue.arg(2);
View Full Code Here

TOP

Related Classes of org.luaj.vm2.lib.IoLib$File

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.