示例#1
0
 /**
  * @param Name
  * @return
  * @throws PDExceptionFunc
  */
 public static String CheckName(String Name) throws PDExceptionFunc {
   // pendiente de resolver compatibilidad con clear()
   if (Name == null) return (Name);
   Name = Name.trim();
   if (Name.length() == 0) PDExceptionFunc.GenPDException("Empty_Name_not_allowed", Name);
   if (Name.length() > 32) PDExceptionFunc.GenPDException("Name_longer_than_allowed", Name);
   for (int i = 0; i < Name.length(); i++) {
     if (AllowedChars.indexOf(Name.charAt(i)) == -1)
       PDExceptionFunc.GenPDException("Character_not_included_in_the_allowed_set", AllowedChars);
   }
   return (Name);
 }
示例#2
0
 /**
  * Updates fields. Syntax: Field1=Field2; Field1=Field1+Field2;
  *
  * @param param Expresión to use
  * @param r Record
  * @return Updates record
  */
 protected Record Update(String param, Record r) throws PDException {
   if (param == null || param.length() == 0) return (r);
   String DestAttr = param.substring(0, param.indexOf('='));
   if (DestAttr.equalsIgnoreCase(PDDocs.fDOCTYPE)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDID)
       || DestAttr.equalsIgnoreCase(PDDocs.fREPOSIT)
       || DestAttr.equalsIgnoreCase(PDDocs.fVERSION)
       || DestAttr.equalsIgnoreCase(PDDocs.fLOCKEDBY)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDAUTOR)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDDATE)
       || DestAttr.equalsIgnoreCase(PDDocs.fSTATUS))
     PDExceptionFunc.GenPDException("Attribute_not_allowed_to_change", DestAttr);
   Attribute Att = r.getAttr(DestAttr);
   String NewExp = param.substring(param.indexOf('=') + 1);
   ArrayList<String> ListElem = new ArrayList<String>(NewExp.length() / 4);
   String Current = "";
   boolean Constant = false;
   for (int i = 0; i < NewExp.length(); i++) {
     char c = NewExp.charAt(i);
     if (c != SYN_SEP && c != SYN_ADD && c != SYN_DEL) Current += c;
     else if (c == SYN_ADD || c == SYN_DEL) {
       if (Current.length() != 0) {
         ListElem.add(Current);
         Current = "";
       }
       ListElem.add("" + c);
     } else if (c == SYN_SEP) {
       Current += c;
       if (Constant) {
         ListElem.add(Current);
         Current = "";
       }
       Constant = !Constant;
     }
   }
   if (Current.length() != 0) {
     ListElem.add(Current);
     Current = "";
   }
   String TotalVal = "";
   String NewVal = "";
   Attribute Attr1 = null;
   for (int i = 0; i < ListElem.size(); i++) {
     if (i % 2 == 0) // Field
     {
       String Elem = ListElem.get(i);
       if (Elem.charAt(0) == SYN_SEP) NewVal = Elem.substring(1, Elem.length() - 1);
       else {
         Attr1 = r.getAttr(Elem);
         NewVal = Attr1.Export();
       }
       if (Current.equals("")) TotalVal = NewVal;
       else if (Current.charAt(0) == SYN_ADD) TotalVal += NewVal;
     } else {
       Current = ListElem.get(i);
     }
   }
   r.getAttr(DestAttr).setValue(TotalVal);
   return (r);
 }
示例#3
0
 /**
  * Obtains te jind of mimetype indcated by Name/extension
  *
  * @param FileName
  * @return String indicating the Name/extension corresponding to file
  * @throws PDException
  */
 public String SolveName(String FileName) throws PDException {
   if (PDLog.isDebug()) PDLog.Debug("PDMimeType.SolveName>:" + FileName);
   String Exten = FileName.substring(FileName.lastIndexOf('.') + 1);
   if (Exten.length() == 0) PDExceptionFunc.GenPDException("Null_Extension", Exten);
   SolveExt(Exten);
   if (PDLog.isDebug()) PDLog.Debug("PDMimeType.SolveName<");
   return (getName());
 }