For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
oracle 21c xe on windows 10 and apex 21.2 problem with autentification required XDB
public static final String names[][] = { {"000000", "Black"}, {"000080", "Navy Blue"}, {"0000C8", "Dark Blue"}, {"0000FF", "Blue"}, ... {"FFFF99", "Pale Canary"}, {"FFFFB4", "Portafino"}, {"FFFFF0", "Ivory"}, {"FFFFFF", "White"} };
CND.Name = "Hodge Podge" CND.Count = 1567 000000 = "Black" 000080 = "Navy Blue" 0000C8 = "Dark Blue" 0000FF = "Blue" ... FFFF99 = "Pale Canary" FFFFB4 = "Portafino" FFFFF0 = "Ivory" FFFFFF = "White"
public class NTC { public final static String defaultCND = new String("cnd_ntc.properties"); private static String cnd_name; ... // encapsulate opening of a properties file. returns null if problem public static Properties loadProperties(String file) { String me = new String("loadProperties(): "); if (file == null) { System.out.println(me + "null filename"); return(null); } Properties p = new Properties(); FileInputStream fis; try { fis = new FileInputStream(file); } catch (FileNotFoundException e) { System.out.println(me + "cannot open " + file); return(null); } try { p.load(fis); } catch (IOException e) { System.out.println(me + "cannot load " + file); try { fis.close(); } catch (IOException ioe) { /* what the heck you gonna do? */ } return(null); } try { fis.close(); } catch (IOException e) { /* what the heck you gonna do? */ } return(p); } // read in a properties file containing a color name dictionary (CND) public static boolean readCND(String cnd) { if (cnd == null) cnd = defaultCND; Properties props = loadProperties(cnd); if (props == null) return(false); ArrayList sorter = new ArrayList(1000); String key; Enumeration hexKeys = props.propertyNames(); while (hexKeys.hasMoreElements()) { key = (String)hexKeys.nextElement(); if (isHex(key)) if (key.length() == 6) sorter.add(key); } int count = sorter.size(); if (count < 1) { System.out.println("readCND(): no hex values in " + cnd); return(false); } // keys were in hashtable order. sort them Collections.sort(sorter); names = new String[count][2]; String name; for (int i = 0; i < count; i++) { name = props.getProperty((String)sorter.get(i), "no name"); names[0] = (String)sorter.get(i); names[i][1] = name; } cnd_name = props.getProperty("CND.name", "unknown"); return (true); } public static String names[][] = { {"000000", "Black"}, {"0000FF", "Blue"}, {"00FF00", "Green"}, {"00FFFF", "Cyan"}, {"FF0000", "Red"}, {"FF00FF", "Magenta"}, {"FFFF00", "Yellow"}, {"FFFFFF", "White"} }; } I did not factor out the loadProperties() part until this morning, when I realized the outer applet will need the same exact code to load the .properties file containing the list of CND .properties files. I also kept a bare-bones dictionary hard-coded in the event even the default CND could not be loaded. The one thing I lost is that the names[][] array is no longer final. External classes can modify it. I know I could make it private and provide access methods, but that would force changes to code already using the class.
public class ColorName extends Color implements Comparable // <ColorName> { private String name, hex; private int hsi, lumi, luma, avg, h_rgb, h_lab, h_hsb; // private Color color; static private List /* <ColorName> */ colorNames; ... public ColorName(String name, String hex) { // I'm a Color now! (needs to be first statement in constructor) super(Integer.valueOf(hex.substring(0,2), 16).intValue(), Integer.valueOf(hex.substring(2,4), 16).intValue(), Integer.valueOf(hex.substring(4,6), 16).intValue()); ... } }
// encapsulate opening of a properties file. returns null if problem public static Properties loadProperties(String file) { String me = new String("loadProperties(): "); if (file == null) { System.out.println(me + "null filename"); return(null); } Properties p = new Properties(); // FileInputStream fis; InputStream fis; try { // fis = new FileInputStream(file); fis = NTC.class.getResourceAsStream("cnd_ntc.properties"); } catch (FileNotFoundException e) { System.out.println(me + "cannot open " + file); return(null); } try { p.load(fis); } catch (IOException e) { System.out.println(me + "cannot load " + file); try { fis.close(); } catch (IOException e2) { /* what the heck you gonna do? */ } return(null); } try { fis.close(); } catch (IOException e) { /* what the heck you gonna do? */ } return(p); } --- compilation error on above --- D:\progming\java\ntc>javac -target 1.4 -source 1.4 NTC.java NTC.java:245: exception java.io.FileNotFoundException is never thrown in body of corresponding try statement } catch (FileNotFoundException e) { ^ 1 error