43 import java.io.UnsupportedEncodingException;
45 import java.net.URLDecoder;
46 import java.nio.charset.Charset;
47 import java.security.CodeSource;
49 import javax.xml.bind.JAXBContext;
50 import javax.xml.bind.JAXBException;
51 import javax.xml.bind.Marshaller;
52 import javax.xml.bind.Unmarshaller;
53 import javax.xml.bind.annotation.XmlElement;
54 import javax.xml.bind.annotation.XmlRootElement;
56 import okw.exceptions.OKWFileDoesNotExistsException;
57 import okw.log.Logger_Sngltn;
291 System.out.println(e.getMessage());
321 public static OKW_Ini_Sngltn getInstance()
324 if (Instance ==
null)
327 synchronized (OKW_Ini_Sngltn.class)
329 if (Instance ==
null)
331 Instance =
new OKW_Ini_Sngltn();
349 public static void Reset()
417 ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
422 URL xml_resource_path = classLoader.getResource(
"xml/logmessages" );
424 if(xml_resource_path !=
null)
428 myPath = URLDecoder.decode( xml_resource_path.getPath(), Charset.defaultCharset().name() );
430 catch (UnsupportedEncodingException e)
436 OKW_Enviroment.setFolder_XML( myPath );
437 Log.
LogPrint(
"Path to resource/xml: '" + myPath +
"'");
439 this.OKW_Enviroment.setFile_OKW_Ini_xml( xml_resource_path.getPath() );
441 this.OKW_Enviroment.setFolder_LogMessages( this.OKW_Enviroment.getFolder_XML() +
"/logmessages" );
443 this.OKW_Enviroment.setFile_OKW_Ini_xml(OKW_Enviroment.getFolder_XML() +
"/OKW_Ini.xml");
448 throw new OKWFileDoesNotExistsException(
"Resource not found: >>" +
"xml/logmessages" +
"<<" );
465 public void Read() throws JAXBException
467 File file =
new File(OKW_Enviroment.getFile_OKW_Ini_xml());
468 JAXBContext jaxbContext = JAXBContext.newInstance(OKW_Ini_Sngltn.class);
470 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
471 OKW_Ini_Sngltn customer = (OKW_Ini_Sngltn) jaxbUnmarshaller.unmarshal(file);
473 System.out.println(customer);
478 System.out.println(
"Enviroment:");
480 System.out.println(
"----------------------------------------------------------------");
481 System.out.println(
" Assambly Path: " + this.MyDirectory());
482 System.out.println(
"----------------------------------------------------------------");
483 System.out.println(
" OKW_Ini.xml Path: " + this.OKW_Enviroment.getFile_OKW_Ini_xml());
484 System.out.println(
" OKW_Const.xml Path: " + this.OKW_Enviroment.getFile_OKW_Const_xml());
485 System.out.println(
" OKW_Docu.xml Path: " + this.OKW_Enviroment.getFile_OKW_Docu_xml());
486 System.out.println(
" OKW_Keymap.xml Path: " + this.OKW_Enviroment.getFile_OKW_Keymaps_xml());
487 System.out.println(
"OKW_Memorize.xml Path: " + this.OKW_Enviroment.getFile_OKW_Memorize_xml());
488 System.out.println(
"----------------------------------------------------------------");
490 "OKW_ImplementationMatrix.xml Path: " + this.OKW_Enviroment.getFile_OKW_ImplementationMatrix_xml());
491 System.out.println(
"----------------------------------------------------------------");
492 System.out.println(
" XML Verzechnis: " + this.OKW_Enviroment.getFolder_XML());
493 System.out.println(
" LogMessanges: " + this.OKW_Enviroment.getFolder_LogMessages());
494 System.out.println(
"----------------------------------------------------------------");
495 System.out.println(
" Language: " + this.OKW_CustomSettings.getLanguage());
496 System.out.println(
" PathSep: " + this.OKW_CustomSettings.getPathSep());
497 System.out.println(
" TimeOutExists: " + this.OKW_CustomSettings.getTimeOutExists());
498 System.out.println(
"TimeOutNotExists: " + this.OKW_CustomSettings.getTimeOutNotExists());
499 System.out.println(
"----------------------------------------------------------------");
518 public void Save() throws JAXBException
520 File file =
new File(OKW_Enviroment.getFile_OKW_Ini_xml());
521 JAXBContext jaxbContext = JAXBContext.newInstance(OKW_Ini_Sngltn.class);
522 Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
525 jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
true);
527 jaxbMarshaller.marshal(
this, file);
528 jaxbMarshaller.marshal(
this, System.out);
540 public String MyDirectory()
542 String lvsReturn =
"";
544 final CodeSource source = this.getClass().getProtectionDomain().getCodeSource();
548 lvsReturn = source.getLocation().getPath();
560 public static Boolean StringIsNullOrEmpty( String fpsString)
563 Boolean lvbReturn =
true;
565 if(fpsString !=
null && !fpsString.isEmpty())