随笔-109  评论-187  文章-25  trackbacks-0
 
 
113:
移位运算符性质
适用数据类型:byte、short、char、int、long,对低于int型的操作数将先自动转换为int型再移位
对于int型整数移位,系统先将b对32取模,得到的结果才是真正移位的位数
对于long型整数移位时 ,则是先将移位位数b对64取模
114:
byte--short--int--long--float--double
     char---/
posted @ 2006-04-13 08:58 小小程序程序员混口饭吃 阅读(161) | 评论 (0)编辑 收藏
     摘要: 一、 Assertion 的语法和语义 J2SE 1.4 在语言上提供了一个新特性,就是assertion(断言)功能,它是该版本在...  阅读全文
posted @ 2006-04-13 08:58 小小程序程序员混口饭吃 阅读(771) | 评论 (0)编辑 收藏

<logic:iterate id="user" property="users" name="usersForm" type="net.wjp.pro.db.entity.logon.User">

< bean:write name="user" property="username"/><br/>

/FONT>

从USERSFORM中取的users的LIST,list里面的type是User

里面的PROPERTY是USERNAME

</logic:iterate >

posted @ 2006-04-13 08:57 小小程序程序员混口饭吃 阅读(250) | 评论 (0)编辑 收藏
 
19:     class A {
public int getNumber(int a) {
    return a + 1;
}
        }
 
        class B extends A {
public int getNumber (int a) {
return a + 2;
        }
 
public static void main (String args[])  {
A a = new B();
14. System.out.printIn(a.getNumber(0));
15.    }
16. }  
What is the result?
A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 13 causes compilation to fail.
E. An error at line 14 causes compilation to fail.
Answer:B。记住一句话,成员变量(编译时)看左边,方法(运行时)看右边。
posted @ 2006-04-13 08:57 小小程序程序员混口饭吃 阅读(918) | 评论 (1)编辑 收藏
 

其实生成JAVADOC很简单,在DOS下用命令而已,生成JAVADOC的目的有2个:

 1:生成DOC

2:检验一下你写的代码时候规范

步骤:

wsad-->window->preference->java->javadoc-->javadoc command-->select the javadoc.exe

java perspective 下面

wsad-->project-->Generate Javadoc-->select package

  next-->next-->input the argument in the javaoptions

ok!你就可以看到生成的文档了,要是CONSOLE有红色的出现,证明你写的程序不规范了,需要修改以下,调整以下,具体参数可以参考JAVADOC命令的参数行:

如下

javadoc: No packages or classes specified.
usage: javadoc [options] [packagenames] [sourcefiles] [classnames] [@files]
-overview           Read overview documentation from HTML file
-public                   Show only public classes and members
-protected                Show protected/public classes and members (default)
-package                  Show package/protected/public classes and members
-private                  Show all classes and members
-help                     Display command line options
-doclet            Generate output via alternate doclet
-docletpath         Specify where to find doclet class files
-1.1                      Generate output using JDK 1.1 emulating doclet
-sourcepath     Specify where to find source files
-classpath      Specify where to find user class files
-bootclasspath Override location of class files loaded
                          by the bootstrap class loader
-extdirs         Override location of installed extensions
-verbose                  Output messages about what Javadoc is doing
-locale             Locale to be used, e.g. en_US or en_US_WIN
-encoding           Source file encoding name
-J                  Pass directly to the runtime system

Provided by Standard doclet:
-d             Destination directory for output files
-use                      Create class and package usage pages
-version                  Include @version paragraphs
-author                   Include @author paragraphs
-splitindex               Split index into one file per letter
-windowtitle        Browser window title for the documenation
-doctitle      Include title for the package index(first) page
-header        Include header text for each page
-footer        Include footer text for each page
-bottom        Include bottom text for each page
-link                Create links to javadoc output at
-linkoffline Link to docs at using package list at
-group :.. Group specified packages together in overview page
-nodeprecated             Do not include @deprecated information
-nosince                  Do not include @since information
-nodeprecatedlist         Do not generate deprecated list
-notree                   Do not generate class hierarchy
-noindex                  Do not generate index
-nohelp                   Do not generate help link
-nonavbar                 Do not generate navigation bar
-serialwarn               Generate warning about @serial tag
-charset         Charset for cross-platform viewing of generated docu
ntation.
-helpfile           Include file that help link links to
-stylesheetfile     File to change style of the generated documentation
-docencoding        Output encoding name

posted @ 2006-04-13 08:56 小小程序程序员混口饭吃 阅读(1765) | 评论 (0)编辑 收藏
 
 

//IJavaProject javaProj = JavaCore.create(proj);

//IProjectDescription des = proj.getDescription();

//IPackageFragmentRoot fragroot = javaProj.getPackageFragmentRoot(folder);

//IPackageFragment frag = fragroot.getPackageFragment(packageName) ;

//{

//frag = fragroot.createPackageFragment(packageName,

//}

//}

//System.out.println(

//}

//try {//if(frag == null || ! frag.exists())true,null);catch(Exception jme) {"Exception in createpackageInStructsProject :" + jme);
posted @ 2006-04-13 08:56 小小程序程序员混口饭吃 阅读(164) | 评论 (0)编辑 收藏
 

1:zoom是如何使用在里面的

    (1)ZoomManager extends ZoomManager
       为visualgroup 增加了zoom
       ===constructor
      public GraphZoomManager(ScalableFigure pane,ViewPoint viewPoint,VisualGroup visualGroup){
        super(pane,viewpoint);
        this.visualGroup = visualGroup;
      }
    (2)override method
       protected void primSetZoom(double zoom){
          super.primSetZoom(zoom);
          getScalableFigure().setScale(1);
          visualGroup.setZoom(zoom);
      }
     (3)在visualGroup setZoom的时候,进行了如下操作
       public void setZoom(double zoom){
          setSize(getWidth()*zoom/getZoom(),getHight().zoom/getZoom());
          super.setZoom(zoom);
          //一下是对里面的点进行zoom
          for(Iterator iter = getVisualVertexList().iterator();iter.hasNext();){
                 VisualVertext vertext = (VisualVertext)iter.next();
                 vertext.setZoom(zoom);
           }


2:gef mvc

 GEF model iteract with controller only,to let controller know model's change ,所以应该把控制器作为事件监听者,注册在模型中,当模型发生变化,就出发相应的时间给控制器,然后负责通知给视图进行更新

3:Design pattern
   OBSERVER的应用http://www.jdon.com/designpatterns/observer.htm这篇文章浅显易懂,很不错的


4:所有事件都在VISUAL model里面,再COMMAND里面的EXECUTE来call
   所有的时间分布再不同的COMMAND的EXECUTE()里面

   policy里面会SET COMMMAND,然后MVC会自动调用里面的EXECUTE方法

   然后去刷新FIGURE
5:orpha

6:ervery visual model -->every visual part-->every visual figure -->one or more policy -->one or more command
7:figure是在MODEL更新完毕之后,有相关的EDIRPART,来监控,就是说OBSERVER来监视当前的EVENT,如果当前EVENT匹配一个
那么会更新一个FIGRUE
   code : visualVertextPart
   editpart ===>c他有多个EDITPART,就跟STRUTS有多个ACTION一个道理。
   GEF肯定也有一个核心的PART,负责整体的流装,但是没有找到是哪一个类。
 public void update(Observer o,Object arg){
    
    //if(type ==locaction) then refresh figure;
    //of course. GEF MVC,已经包装好了,就不用我们考虑了,只需要你去做填鸭就可以了,:)
   if (VisualGraphConstant.LOCATION.equals(type))
        {
            IFigure figure = getFigure();
            VisualVertex visualVertex = getVisualVertex();
            figure.setLocation(new Point(visualVertex.getX(), visualVertex
                    .getY()));
        }

}
8;property 和outline是怎么加上去的??放在明天看吧


9:toolbar跟 MENU是怎么加上去的:
   toobar 是在PLUGIN.XML的ContributorClass 中加上去的,可以先看一下

   extends ActionBarContributor
   TOOLbar的东西ECLIPSE已经封装的很好了,发现GEF真是了不起啊

   menu是如何加上去的

   都是在EDITOR里面的CREATEACTIONS里面加上去的,OVERRIDES createActions method()

   code as following
     pretected void createActions(){
        super.createActions();
        IAction zoomInAction = new ZoomInAction(getZoomManager());
        IAction zoomOutAction = new ZoomOutAction(getZoomManager());
        addAction(zoomInAction());
        addAction(zoomOutAction());
        addAction(new OpenPropertiesViewAction());
     }

   OpenPropertiesViewActions code as follows

    1:利用现在的PROPERTIES的view,open properties sheet,ok...


   OpendataPropertiesViewAction code as follwos
     
    2:新建一个dataPropertiesViewAction

     
       

posted on 2006
posted @ 2006-04-13 08:56 小小程序程序员混口饭吃 阅读(177) | 评论 (0)编辑 收藏
 

1:GEF mvc framework

2:policy 所有的POLICY应该是注册在visual....part中的
  每一个POLICY来生命相应的COMMMAND,可能会对应多个COMMMAND
3:visualGraph -->rootEditpart--->

  configureGraphviewer()
     ---super.configureGraphviewer()
     ---getGraphicalViewer().setRootEditPart(rootEditPart);
     ---getGraphicalViewer().setEditPartFactory(new GraphEdirPartFactory());
   以上属于把ROOTEDITPART和EDIRPARTFACTORY()注册到当前的Graphicalviewer当中
   内部已经已经封装好了监听,就跟STRUT一样,你配置好,提交的时候就会又相应的ACTION去执行他,

    CONFIG--->STRUTS-CONFIG  =======  当前的REISTRY graphicalView().set()....
    control核心  -->strust-actionServlet 和requestProcessor =======   当前的editpart 的GraphEditPartFactory();
    实际的action   struts-action =========每个editpart --->policy -- >可能对应多格COMMAND

4:commmandstack.addCommandStackListner();
   getSite().getWorkBenchWindow().getSelectionService().addSelectionListener(this)

   rootEidtpart.getZoomManger();

   ZoomManger也是ACTION所以就注册在了EDITPART中了
   
5:我的疑问:
   FIGURE和VERTEX GROUP,EDGE,GRAP的关系,是最小的????
   FIGURE是未来显示在EDITOR里面的最小单元???

6:EDITOR里面的CreateGraphicalViewer(Composite composite)


7:editpart initialize the editdomain,viewers,palette,
  editpart bootstraps the editpartviewers as content;

8:
     Model:
          The model should be changed using commands

     View:
          View can bi several things
          (1) visual part,which serves as the primary represention for model object  
          (2) the most flexible visual part are Figures form drar2d
     Cotroler:
          (1)a controller is an editpart,Editparts are the bread-and-butter of GEF
          (2) the entire view is managed by Editpart
          (3) editPart's responsibility is to manipulate the model with commands,complex model can lead to

complex commands
          (4)to make editpart's job easier,each role is implemented by a pluggable object called editpolicy


9: Result:
    (1)edit part reprents a single conceptual object with which user can use direct or indirect interact
       but an editpart itself is not visible to user,but will represent itself through it's view              
 

10:
    (1)
   each editpart istall one or more editpolicies,editpart foward edit request to every installed editPolicy

=================================11:Using EditPolicies,request,roles===============


 (1)Editpolicy

    an editpart iterates over all it's policies to handle requests,but editpolicy ignore the request

 (2)role
    as i understand ,role is string ,like COMPONENT_ROLE..
 (3)request
    are used to communicate with an editpart


 (4) role and editpolicies in GEF are partitioned into two basic types:graphical and non-graphical

  

posted @ 2006-04-13 08:55 小小程序程序员混口饭吃 阅读(207) | 评论 (0)编辑 收藏
 

2005-10-20 16:30:46

正则表达式(regular expression)对象包含一个正则表达式模式(pattern)。它具有用正则表达式模式去匹配或代替一个字符串(string)中特定字符(或字符集合)的属性(properties)和方法(methods)。 要为一个单独的正则表达式添加属性,可以使用正则表达式构造函数(constructor function),无论何时被调用的预设置的正则表达式拥有静态的属性(the predefined RegExp object has static properties that are set whenever any regular expression is used, 我不知道我翻得对不对,将原文列出,请自行翻译)。

创建:
一个文本格式或正则表达式构造函数
文本格式: /pattern/flags
正则表达式构造函数: new RegExp("pattern"[,"flags"]);
参数说明:
pattern -- 一个正则表达式文本
flags -- 如果存在,将是以下值:
g: 全局匹配
i: 忽略大小写
gi: 以上组合
[注意] 文本格式的参数不用引号,而在用构造函数时的参数需要引号。如:/ab+c/i new RegExp("ab+c","i")是实现一样的功能。
在构造函数中,一些特殊字符需要进行转意(在特殊字符前加"\")。如:re = new RegExp("\\w+")

正则表达式中的特殊字符

字符 含意
\ 做为转意,即通常在"\"后面的字符不按原来意义解释,如/b/匹配字符"b",当b前面加了反斜杆后/\b/,转意为匹配一个单词的边界。
-或-
对正则表达式功能字符的还原,如"*"匹配它前面元字符0次或多次,/a*/将匹配a,aa,aaa,加了"\"后,/a\*/将只匹配"a*"。

^ 匹配一个输入或一行的开头,/^a/匹配"an A",而不匹配"An a"
$ 匹配一个输入或一行的结尾,/a$/匹配"An a",而不匹配"an A"
* 匹配前面元字符0次或多次,/ba*/将匹配b,ba,baa,baaa
+ 匹配前面元字符1次或多次,/ba*/将匹配ba,baa,baaa
? 匹配前面元字符0次或1次,/ba*/将匹配b,ba
(x) 匹配x保存x在名为$1...$9的变量中
x|y 匹配x或y
{n} 精确匹配n次
{n,} 匹配n次以上
{n,m} 匹配n-m次
[xyz] 字符集(character set),匹配这个集合中的任一一个字符(或元字符)
[^xyz] 不匹配这个集合中的任何一个字符
[\b] 匹配一个退格符
\b 匹配一个单词的边界
\B 匹配一个单词的非边界
\cX 这儿,X是一个控制符,/\cM/匹配Ctrl-M
\d 匹配一个字数字符,/\d/ = /[0-9]/
\D 匹配一个非字数字符,/\D/ = /[^0-9]/
\n 匹配一个换行符
\r 匹配一个回车符
\s 匹配一个空白字符,包括\n,\r,\f,\t,\v等
\S 匹配一个非空白字符,等于/[^\n\f\r\t\v]/
\t 匹配一个制表符
\v 匹配一个重直制表符
\w 匹配一个可以组成单词的字符(alphanumeric,这是我的意译,含数字),包括下划线,如[\w]匹配"$5.98"中的5,等于[a-zA-Z0-9]
\W 匹配一个不可以组成单词的字符,如[\W]匹配"$5.98"中的$,等于[^a-zA-Z0-9]。



说了这么多了,我们来看一些正则表达式的实际应用的例子:

E-mail地址验证:
function test_email(strEmail) {
var myReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
if(myReg.test(strEmail)) return true;
return false;
}
HTML代码的屏蔽
function mask_HTMLCode(strInput) {
var myReg = /<(\w+)>/;
return strInput.replace(myReg, "<$1>");
}

正则表达式对象的属性及方法
  预定义的正则表达式拥有有以下静态属性:input, multiline, lastMatch, lastParen, leftContext, rightContext和$1到$9。
其中input和multiline可以预设置。其他属性的值在执行过exec或test方法后被根据不同条件赋以不同的值。
许多属性同时拥有长和短(perl风格)的两个名字,并且,这两个名字指向同一个值。(JavaScript模拟perl的正则表达式)

正则表达式对象的属性 属性 含义
$1...$9 如果它(们)存在,是匹配到的子串
$_ 参见input
$* 参见multiline
$& 参见lastMatch
$+ 参见lastParen
$` 参见leftContext
$’          参见rightContext
constructor    创建一个对象的一个特殊的函数原型
global       是否在整个串中匹配(bool型)
ignoreCase     匹配时是否忽略大小写(bool型)
input        被匹配的串
lastIndex     最后一次匹配的索引
lastParen     最后一个括号括起来的子串
leftContext    最近一次匹配以左的子串
multiline     是否进行多行匹配(bool型)
prototype     允许附加属性给对象
rightContext    最近一次匹配以右的子串
source       正则表达式模式
lastIndex     最后一次匹配的索引


正则表达式对象的方法
方法 含义
compile      正则表达式比较
exec        执行查找
test        进行匹配
toSource      返回特定对象的定义(literal representing),其值可用来创建一个新的对象。重载Object.toSource方法得到的。
toString      返回特定对象的串。重载Object.toString方法得到的。
valueOf      返回特定对象的原始值。重载Object.valueOf方法得到

例子
Smith, John
将输出"Smith, John"

 
posted @ 2006-04-13 08:55 小小程序程序员混口饭吃 阅读(205) | 评论 (0)编辑 收藏
 

JSTL包含以下的标签:
   常用的标签:如<c:out>、<c:remove>、<c:catch>、<c:set>等
   条件标签:如<c:if><c:when>、<c:choose>、<c:otherwise>等
   URL标签:如<c:import>、<c:redirect>和<c:url>等
   XML标签:如<xml:out>等
   国际化输出标签:如<fmt:timeZone>等
   SQL标签:如<sql:query>、<sql:update>、<sql:transaction>等
 
一般用途的标签:
1.<c:out>
没有Body时的语法
<c:out value="value" [escapeXml="{true|false}"] [default="defaultValue"]/>
有Body时的语法
<c:out value="value" [escapeXml="{true|false}"]>
这里是Body部分
</c:out>
名字                  类型               描述
value               Object         将要输出的表达式
escapeXml    boolean      确定以下字符:<,>,&,',"在字符串中是否被除数,默认为true
default            Object          如果vaule计算后的结果是null,那么输出这个默认值

2.<c:set>
这个标签用于在某个范围(page、request、session、application等)中使用某个名字设定特定的值,或者设定某个已经存在的javabean对象的属性。他类似于<%request.setAttrbute("name","value");%>
语法1:使用value属性设定一个特定范围中的属性。
<c:set value="value" var="varName" [scope="{page|request|session|application}"]/>
语法2:使用value属性设定一个特定范围中的属性,并带有一个Body。
<c:set var="varName" [scope="{page|request|session|application}"]>
Body部分
</c:set>
语法3:设置某个特定对象的一个属性。
<c:set value="value" target="target" property="propertyName"/>
语法4:设置某个特定对象的一个属性,并带有一个Body。
<c:set target="target" property="propertyName">
Body部分
</c:set>

名字             类型                         描述
value            Object           将要计算的表到式。
var                String            用于表示value 值的属性,如果要在其他标签中使用,就是通过这 个var指定的值来进行的。它相当于在标签定义了一个变量,并且这个变量只能在标签中的一个。
scope          String             var的有效范围,可以是page|request|session|application中的一个
target           String           将要设置属性的对象,它必须是javabean或则java.util.Map对象
property       Object           待设定的Target对象中的属性名字,比如在javabean中有个name属性,提供了setUserId方法,那么这里填userId。

3.<c:remove>
<c:remove var="varName" [scope="{page|request|session|application}"]/>

4.<c:catch>
这个标签相当于捕获在它里边的标签抛出的异常对象
<c:catch [var="varName"]> //var是异常的名字
内容
</c:catch>

条件标签
1. <c:if>
语法1:无Body情况
<c:if test="testCondition" var="varName" [scope="page|request|session|application"]/>
语法2:有Body的情况
<c:if test="testCondition" var="varName" [scope="page|request|session|application"]>
Body内容
</c:if>

名字 类型 描述
test Boolean 表达式的条件,相当于if()中的条件判断语句。
var String 表示这个语句的名字。
scope String var这个变量的作用范围。

2.<c:choose>
语法:<c:choose>
Body内容(<c:when>和<c:otherwise>子标签)
</c:choose>
注意:它的Body只能由以下元素组成:
1) 空格
2) 0或多个<c:when>子标签,<c:when>必须在<c:otherwise>标签之前出现.
3) 0个或多个<c:otherwise>子标签。

3.<c:when>
代表的是<c:choose>的一个条件分支,只能在<c:choose>中使用
语法:<c:when test="testCondition"> //test是boolean类型,用于判断条件真假
Body语句
</c:when>

4.<c:otherwise>
代表的是<c:choose>中的最后选择。必须在最后出现
<c:otherwise>
内容
</c:otherwise>

迭代标签
1.<c:forEach>
语法1:在Collection中迭代
<c:forEach[var="varName"] items="collection" [varStatus="varStatusName"]
[begin="begin"] [end="end"] [step="step"]
Body内容
</c:foeEach>

语法2:迭代固定的次数.
<c:forEach [var="varName"] [varStatus="varStatusName"]
[begin="begin"] [end="end"] [step="step"]
Body内容
</c:foeEach>

名字               类型                                    描述
var                 String                                迭代的参数,它是标签参数,在其他标签中通过它来引用这个标签中的内容。
Items           Collection、ArrayList、  要迭代的items集合.
                     Iterator、Map、String、
                      Eunmeration等
VarStatus   String                                  表示迭代的状态,可以访问迭代自身的信息
Begin          int                                        表示开始迭代的位置。
End              int                                       表示结束迭代的位置。
Step            int                                        表示迭代移动的步长,默认为1。

URL相关的标签
1.<c:import>
语法1:资源的内容使用String对象向外暴露
<c:import url="url" [context="context"]
[var="varName"] [scope="{page|request|session|application}"] [charEncoding="charEncoding"]>
内容
</c:import>

语法2:资源的内容使用Reader对象向外暴露。
<c:import url="url" [context="context"]
varReader="varReaderName" [charEncoding="charEncoding"]>
内容
</c:import>
名字                  类型                               描述
url                     String                     待导入资源的URL,可以是相对路径和绝对路径,并且可以导入其他主机资源
context             String                     当使用相对路径访问外部context资源时,context指定了这个资源的名字。
var                     String                    参数的名字。
scope               String                    var参数的作用范围。
cahrEncoding String                    输入资源的字符编码。
varReader       String                    这个参数的类型是Reader,用于读取资源。

2.<c:redirct>
语法1:没有Body的情况.
<c:redirect url="value" [context="context"]/>
语法2:有Body情况下,在Body中指定查询的参数
<c:redirect url="value" [context="context"]>
<c:param name="name" value="value"/>
</c:redirect>

3.<c:url>
语法1:没有Body
<c:url value="value" [context="context"] [var="varName"] [scope="{page|request|session+application}"]/>
语法2:有Body
<c:url value="value" [context="context"] [var="varName"] [scope="{page|request|session+application}"]>
<c:param name="name" value="value"/>
</c:url>

名字                  类型                  描述
value             String                URL值
context          String                 当使用相对路径访问外部context资源时,context指定了这个资源的名字
var                 String                 标识这个URL标量。
Scope           String                变量作用范围。

SQL相关的标签
1.<sql:setDataSource>
2.<sql:query>
3.<sql:update>
4.<transaction>
5.<param>

 

posted @ 2006-04-13 08:54 小小程序程序员混口饭吃 阅读(869) | 评论 (0)编辑 收藏
仅列出标题
共11页: First 上一页 3 4 5 6 7 8 9 10 11 下一页