Java Code Examples for java.nio.file.Path#contains()

The following examples show how to use java.nio.file.Path#contains() . These examples are extracted from open source projects. 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
/**
 * Import a Doc described by an XML with content referenced
 * @param OPDObject XMLNode to process
 * @param DestFold OPD destination folder
 * @param MaintainId When true, the Original Id is maintained, else a new one is assigned
 * @return The Id of the imported document
 * @throws PDException In any error
 */
public String ImportXMLNode(Node OPDObject, String DestFold, boolean MaintainId) throws PDException
{
if (PDLog.isInfo())
    PDLog.Debug("PDDocs.ImportXMLNode>:B64. DestFold="+DestFold+" MaintainId="+MaintainId+" OPDObject="+OPDObject);    
NodeList childNodes = OPDObject.getChildNodes();
PDDocs NewDoc=null;
for (int i = 0; i < childNodes.getLength(); i++)
    {
    Node item = childNodes.item(i);
    if (item.getNodeName().equalsIgnoreCase(XML_ListAttr)) 
        {
        Record r=Record.FillFromXML(item, getRecord());
        String DocTypReaded=(String)r.getAttr(PDDocs.fDOCTYPE).getValue();
        NewDoc=new PDDocs(getDrv(), DocTypReaded); // to be improved to analize the type BEFORE
        r=Record.FillFromXML(item, NewDoc.getRecSum());
        NewDoc.assignValues(r);
        if (!MaintainId && ExistId(NewDoc.getPDId()))
           NewDoc.setPDId(null);
        NewDoc.setParentId(DestFold);
        PDRepository Rep=new PDRepository(getDrv());
        Rep.Load(NewDoc.getReposit());
        if (!Rep.IsRef())
            {
            Attribute DocName=r.getAttr(fNAME);
            String Path=(String)DocName.getValue();
            if (!Path.contains(File.separator)) // if absolute reference, maintain
                NewDoc.setName(null); // calculated by when inserting
            }
        }
    else if (item.getNodeName().equalsIgnoreCase(XML_CONTENT)) 
        {
        NewDoc.setStreamB64(new ByteArrayInputStream(item.getTextContent().getBytes()));
        }
    }
if (PDLog.isDebug())
    PDLog.Debug("PDDocs.ImportXMLNode<");    
NewDoc.insert();
return(NewDoc.getPDId());
}
 
Example 2
/**
 * Import a Doc described by an XML with content referenced
 * @param OPDObject XMLNode to process
 * @param FolderPath Path where the original xlml file was readed. Use to resolve the absolute file position
 * @param DestFold OPD destination folder
 * @param MaintainId When true, the Original Id is maintained, else a new one is assigned
 * @throws PDException In any error
 */
public void ImportXMLNode(Node OPDObject, String FolderPath, String DestFold, boolean MaintainId) throws PDException
{
if (PDLog.isInfo())
    PDLog.Debug("PDDocs.ImportXMLNode>:FolderPath="+FolderPath+" DestFold="+DestFold+" MaintainId="+MaintainId+" OPDObject="+OPDObject);    
//if (FolderPath.charAt(FolderPath.length()-1)!=File.separatorChar)
//    FolderPath+=File.separatorChar; 
FolderPath=DriverGeneric.FixPath(FolderPath, true);
NodeList childNodes = OPDObject.getChildNodes();
PDDocs NewDoc=null;
PDObjDefs DefDoc=new PDObjDefs(getDrv());
for (int i = 0; i < childNodes.getLength(); i++)
    {
    Node item = childNodes.item(i);
    if (item.getNodeName().equalsIgnoreCase(XML_ListAttr)) 
        {
        Record r=Record.FillFromXML(item, getRecord());
        String DocTypReaded=(String)r.getAttr(PDDocs.fDOCTYPE).getValue();
        if (DefDoc.Load(DocTypReaded)==null)
           throw new PDException("Unknown_DocType"+":"+DocTypReaded);  
        NewDoc=new PDDocs(getDrv(), DocTypReaded); // to be improved to analize the type BEFORE
        r=Record.FillFromXML(item, NewDoc.getRecSum());
        NewDoc.assignValues(r);
        if (!MaintainId)
            NewDoc.setPDId(null);
        NewDoc.setParentId(DestFold);
        PDRepository Rep=new PDRepository(getDrv());
        Rep.Load(DefDoc.getReposit()); // definiton of type NOT XML imported
        if (!Rep.IsRef())
            {
            Attribute DocName=r.getAttr(fNAME);
            String Path=(String)DocName.getValue();
            if (Path.contains(File.separator)) // if absolute reference, maintain
                NewDoc.setFile(Path);
            else
                {
                if (Path.contains("&amp;") || Path.contains("&gt;") || Path.contains("&lt;") ) 
                    { // Testing name conversion
                    File f=new File(FolderPath+Path);
                    if (!f.exists()) // perhaps converted
                        {
                        Path=Path.replace("&lt;", "<").replace("&gt;", ">" ).replace("&amp;", "&");   
                        }
                    }
                NewDoc.setFile(FolderPath+Path);
                }
            NewDoc.setName(null); // calculated by when inserting
            }
        }
    }
if (PDLog.isDebug())
    PDLog.Debug("PDDocs.ImportXMLNode<");    
NewDoc.insert();
}