- "Effetive Java" item 58: Use checked exceptions for recoverable conditions and runtime exceptions for programming errors
- http://marxsoftware.blogspot.com/2010/04/i-recently-wrote-that-chapter-in.html
Tuesday, August 23, 2011
Thursday, August 11, 2011
BufferredReader
| The Reader.ready() and InputStream.available() rarely work as you might like, and I don't suggest you use them. To read a file you should use |
http://stackoverflow.com/questions/5244839/dose-bufferedreader-ready-method-ensure-that-readline-method-does-not-return
BufferedReader reader=null;
try {
reader = new BufferedReader(new StringReader("ABCD"));
while (reader.ready()) {
final String line = reader.readLine();
System.out.println("<"+line+">");
} catch (..)
{
...
}
So a BufferedReader is considered ready simply if the underlying stream is also ready. Since BufferedReader is a wrapper, this underlying stream could be any Reader implementation; hence the semantics of
ready() are those declared on the interface:Returns true if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.So you only really get timing guarantees, i.e. that
read() will not block. The result of calling ready() tells you absolutely nothing about the content you'll get back from a read() call, and so cannot be used to elide a null check.
Tuesday, August 2, 2011
file name to java.io.File
String filePath = "com/?/work?/rest/resource/" + fileName;
java.net.URL fileUrl = getClass().getClassLoader().getResource(filePath);
java.io.File rawFileData = new File (filUrl.toURI());
Thursday, July 28, 2011
after using dojo.mixin(), need to do some post op to get rid of all 'undefined' values that passed into constructor
after using dojo.mixin(this, p_args); have to make sure that neither of the defined as member variable is 'undefined' and note that 'undefined' can be pass into the constructor (which is different from where the parameter is not given at all) will override that '' default value.
other wise will get something like
"error: Error: *.widget.SummaryRow
template: library"
so need to do some post op to get rid of all 'undefined' values.
------------------------------------------------------------
dojo.provide("*.widget.SummaryRow");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("*.widget.SummaryRow", [ dijit._Widget,
dijit._Templated ], {
// Path to the template
templateString : dojo.cache("*.widget",
"templates/SummaryRow.html"),
widgetsInTemplate : false,
checkboxtitle : null,
image : '',
title : '',
author : '',
workflowstatus : '',
description : '',
contextpath : '',
library : '',
links : '',
constructor : function(p_args) {
dojo.mixin(this, p_args);
},
postMixInProperties : function() {
alert("in postMixInProperties");
this.library = this.getLibraryUuid(this.links);
},
getLibraryUuid : function(p_links) {
alert("in getLibraryUuid(): p_links: " + p_links);
return "WebContent";
},
postCreate : function() {
this.inherited(arguments);
}
});
other wise will get something like
"error: Error: *.widget.SummaryRow
template: library"
so need to do some post op to get rid of all 'undefined' values.
------------------------------------------------------------
dojo.provide("*.widget.SummaryRow");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("*.widget.SummaryRow", [ dijit._Widget,
dijit._Templated ], {
// Path to the template
templateString : dojo.cache("*.widget",
"templates/SummaryRow.html"),
widgetsInTemplate : false,
checkboxtitle : null,
image : '',
title : '',
author : '',
workflowstatus : '',
description : '',
contextpath : '',
library : '',
links : '',
constructor : function(p_args) {
dojo.mixin(this, p_args);
},
postMixInProperties : function() {
alert("in postMixInProperties");
this.library = this.getLibraryUuid(this.links);
},
getLibraryUuid : function(p_links) {
alert("in getLibraryUuid(): p_links: " + p_links);
return "WebContent";
},
postCreate : function() {
this.inherited(arguments);
}
});
Monday, July 25, 2011
Handle Parameters Override for RESTful service
1. Allow the user of the RESTful Service to be able to specify parameter that overrides attributes in the header is good practice since it is not always convenient for the user writing the client application to specify the attributes in the request header
2. For example, dojox.rpc.REST(<url>, <isJson>), a nice functionality, but you can't really explicitly specify what the 'Content-type' is except for whether it is application/json or not. But if the corresponding RESTful service handles parameter override, then the user can conveniently just put that into the <url>.
3. Arguably this deviate from the how REST should be different RPC, but practically, who cares?
2. For example, dojox.rpc.REST(<url>, <isJson>), a nice functionality, but you can't really explicitly specify what the 'Content-type' is except for whether it is application/json or not. But if the corresponding RESTful service handles parameter override, then the user can conveniently just put that into the <url>.
3. Arguably this deviate from the how REST should be different RPC, but practically, who cares?
opacity, z-index,
in Style
opacity: transparency, 0 is lowest, 1 is highest - in FF; IE is 0-100
z-index: layering, the higher the more on top the layer.
opacity: transparency, 0 is lowest, 1 is highest - in FF; IE is 0-100
z-index: layering, the higher the more on top the layer.
Subscribe to:
Posts (Atom)