Package org.openquark.cal.machine

Examples of org.openquark.cal.machine.ProgramResourceLocator$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

                // (Set of ProgramResourceLocator)
                Set<ProgramResourceLocator> deleteSet = new HashSet<ProgramResourceLocator>();

                for (int i = 0; i < folderMembers.length; ++i) {
                    ProgramResourceLocator folderMember = folderMembers[i];
                    String name = folderMembers[i].getName();

                    if (!currentFileSet.contains(name)) {
                        deleteSet.add(folderMember);
                    }
View Full Code Here

                }
                Set<LECCModule> dependeeModuleSet = getDependeeModuleSet();
                List<LECCModule> dependeeModuleList = new ArrayList<LECCModule>(dependeeModuleSet);

                // Use the CALClassLoader factory method to create a class loader instance.
                ProgramResourceLocator moduleFolderLocator = new ProgramResourceLocator.Folder(getName(), ResourcePath.EMPTY_PATH);
                classLoader = CALClassLoader.makeCALClassLoader(resourceRepository, moduleFolderLocator, getForeignClassLoader(), this, dependeeModuleList);
            }

            return classLoader;
        }
View Full Code Here

       
        ProgramResourceLocator[] members = resourceRepository.getMembers(moduleFolder);
       
        for (int fileN = 0, nFiles = members.length; fileN < nFiles; ++fileN) {
           
            ProgramResourceLocator member = members[fileN];
            String name = member.getName();
           
            // Skip anything which isn't a class file.
            if (!(member instanceof ProgramResourceLocator.File) || !name.toLowerCase().endsWith(".class")) {
                continue;
            }
            ProgramResourceLocator.File classFileLocator = (ProgramResourceLocator.File)member;
           
            byte[] bytecode;
            InputStream classFileContents = null;
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                classFileContents = resourceRepository.getContents(classFileLocator);
                byte[] buf = new byte[4096];
               
                while (true) {
                    int bytesRead = classFileContents.read(buf);
                    if (bytesRead < 0) {
                        break;
                    }
                   
                    baos.write(buf, 0, bytesRead);
                }
               
                bytecode = baos.toByteArray();
               
            } catch (IOException ioe) {
                throw new RuntimeException("Could not read the class file " + member.getName() + ".");
               
            } finally {
                if (classFileContents != null) {
                    try {
                        classFileContents.close();
                    } catch (IOException e) {
                    }
                }
            }
                            
            final boolean dumpAsmifiedText = true;
            final boolean dumpDisassembledText = true;
            final boolean verifyClassFileFormat = true;           
           
            //javac generates many debug op codes, such as line number annotations. For comparison with the asm
            //generated byte codes we can skip these.
            final boolean skipDebugOpCodes = true;
           
            final boolean skipInnerClassAttributes = false;
                 
            String classFileName = member.getName();           
            String className = classFileName.substring(0, classFileName.length() - ".class".length());
            String moduleName = moduleFolder.getModuleName().toString().replaceAll("_", "__").replace('.', '_');          
                   
            if (dumpAsmifiedText) {
                String asmifierDumpPath = "d:\\dev\\asmifierOutput\\javaSource\\" + moduleName + "\\" + className + ".txt"
View Full Code Here

TOP

Related Classes of org.openquark.cal.machine.ProgramResourceLocator$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.