什么是Java内容仓库

Python013

什么是Java内容仓库,第1张

java内容仓库是JSR-170中定义的一个内容存储的规范。JSR-170试图建立一套标准的API去访问内容仓库。如果你对内容管理系统(CMS)不熟悉的话,你一定会对内容仓库是什么感到疑惑。你可以这样去理解,把内容仓库理解为一个用来存储文本和二进制数据(图片,word文档,PDF等等)的数据存储应用程序。一个显著的特点是你不用关心你真正的数据到底存储在什么地方,是关系数据库?是文件系统?还是XML?不仅仅是数据的存储和读取,大多数的内容仓库还提供了更加高级的功能,例如访问控制,查找,版本控制,锁定内容等等。

import java.util.*

import java.awt.event.*

import java.awt.*

import javax.swing.*

import java.io.*

class 商品 extends Panel

{String 代号,名称int 库存float 单价<br/>商品(String 代号,String 名称,int 库存,float 单价) <br/>{this.代号=代号this.名称=名称this.库存=库存this.单价=单价<br/>}

}

class ShowWin extends JFrame implements ActionListener

{ Hashtable hashtable=null

JTextField 代号文本框=new JTextField(),

名称文本框=new JTextField(),

库存文本框=new JTextField(),

单价文本框=new JTextField(),

查询文本框=new JTextField(),

查询信息文本框=new JTextField(),

删除文本框=new JTextField()

JButton b_add=new JButton("添加商品"),

b_del=new JButton("删除商品"),

b_xun=new JButton("查询商品"),

b_xiu=new JButton("修改商品"),

b_show=new JButton("显示商品清单")

JTextArea 显示区=new JTextArea(25,10)

ShowWin()

{super("仓库管理窗口")<br/>hashtable=new Hashtable()<br/>Container con=getContentPane()<br/>JScrollPane pane=new JScrollPane(显示区)<br/>显示区.setEditable(false)<br/>JPanel save=new JPanel()<br/>save.setLayout(new GridLayout(8,2))<br/>save.add(new Label("输入代号:"))<br/>save.add(代号文本框)<br/>save.add(new Label("输入名称:"))<br/>save.add(名称文本框)<br/>save.add(new Label("输入库存:"))</pre></div> <div class="replenish min_margin"> <dl><dt> 补充: </dt><dd> save.add(库存文本框)<br/>save.add(new Label("输入单价:"))<br/>save.add(单价文本框)<br/>save.add(new Label("单击添加:"))<br/>save.add(b_add)<br/>save.add(new Label("单击修改:"))<br/>save.add(b_xiu)<br/>save.add(new Label("输入查询代号:"))<br/>save.add(查询文本框)<br/>save.add(new Label("单击查询:"))<br/>save.add(b_xun)<br/>JPanel del=new JPanel()<br/>del.setLayout(new GridLayout(2,2))<br/>del.add(new Label("输入删除的代号:"))<br/>del.add(删除文本框)<br/>del.add(new Label("单击删除:"))<br/>del.add(b_del)<br/>JPanel show=new JPanel()<br/>show.setLayout(new BorderLayout())<br/>show.add(pane,BorderLayout.CENTER)<br/>show.add(b_show,BorderLayout.SOUTH)<br/>JSplitPane split_one,split_two<br/>split_one=new JSplitPane(JSplitPane.VERTICAL_SPLIT,save,del)<br/>split_two=new <br/>JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,split_one,show)<br/>con.add(split_two,BorderLayout.CENTER)<br/>JPanel xun=new JPanel()<br/>xun.add(new Label("所得信息:"))<br/>xun.add(查询信息文本框)<br/>xun.setLayout(new GridLayout(2,1))<br/>con.add(xun,BorderLayout.SOUTH)<br/>b_add.addActionListener(this) </dd></dl> <dl><dt> 补充: </dt><dd> b_del.addActionListener(this)<br/>b_xun.addActionListener(this)<br/>b_xiu.addActionListener(this)<br/>b_show.addActionListener(this)<br/>}

public void actionPerformed(ActionEvent e)

{if(e.getSource()==b_add) <br/>{String daihao=null,mingcheng=nullint kucun=0float danjia=0.0f<br/>daihao=代号文本框.getText()mingcheng=名称文本框.getText()<br/>kucun=Integer.parseInt(库存文本框.getText())<br/>danjia=Float.valueOf(单价文本框.getText()).floatValue()<br/>商品 goods=new 商品(daihao,mingcheng,kucun,danjia)<br/>hashtable.put(daihao,goods)<br/>try{FileOutputStream file=new FileOutputStream("goods.txt")<br/>ObjectOutputStream out=new ObjectOutputStream(file)<br/>out.writeObject(hashtable)out.close()<br/>}

catch(IOException event){}

}

else if(e.getSource()==b_del)

{String daihao1=删除文本框.getText()<br/>try{FileInputStream come_in=new FileInputStream("goods.txt")<br/>ObjectInputStream in=new ObjectInputStream(come_in)<br/>hashtable=(Hashtable)in.readObject()////// <br/>in.close()<br/>}</dd></dl>补充: catch(ClassNotFoundException event){}

catch(IOException event){}

商品 temp=(商品)hashtable.get(daihao1)

{hashtable.remove(daihao1)}

try{FileOutputStream file=new FileOutputStream("goods.txt")<br/>ObjectOutputStream out =new ObjectOutputStream(file)<br/>out.writeObject(hashtable)// <br/>out.close()<br/>}

catch(IOException event){}

}

//

else if(e.getSource()==b_xun)

{ String aa

aa=查询文本框.getText()

查询信息文本框.setText(null)

try{FileInputStream come_in=new FileInputStream("goods.txt")<br/>ObjectInputStream in =new ObjectInputStream(come_in)<br/>hashtable=(Hashtable)in.readObject()//// <br/>in.close()<br/>}

catch(ClassNotFoundException event){}

catch(IOException event){}

商品 a=(商品)hashtable.get(aa)

查询信息文本框.setText(" 代号:"+a.代号+" 名称:"+a.名称+" 库存:"+a.库存+" 单价:"+a.单价)

}

//

else if(e.getSource()==b_xiu)

{ String bb

bb=代号文本框.getText()

try{FileInputStream come_in=new FileInputStream("goods.txt")<br/>ObjectInputStream in=new ObjectInputStream(come_in) </dd></dl> <dl><dt> 补充: </dt><dd> hashtable=(Hashtable)in.readObject()////// <br/>in.close()<br/>}

catch(ClassNotFoundException event){}

catch(IOException event){}

商品 temp=(商品)hashtable.get(bb)

{hashtable.remove(bb)}

try{FileOutputStream file=new FileOutputStream("goods.txt")<br/>ObjectOutputStream out =new ObjectOutputStream(file)<br/>out.writeObject(hashtable)// <br/>out.close()<br/>}

catch(IOException event){}

String daihao1=null,mingcheng1=nullint kucun1=0float danjia1=0.0f

daihao1=代号文本框.getText()mingcheng1=名称文本框.getText()

kucun1=Integer.parseInt(库存文本框.getText())

danjia1=Float.valueOf(单价文本框.getText()).floatValue()

商品 goods1=new 商品(daihao1,mingcheng1,kucun1,danjia1)

hashtable.put(daihao1,goods1)

try{FileOutputStream file=new FileOutputStream("goods.txt")<br/>ObjectOutputStream out=new ObjectOutputStream(file)<br/>out.writeObject(hashtable)out.close()<br/>}

catch(IOException event){}

}

//

else if(e.getSource()==b_show)

{ 显示区.setText(null) 补充: try{FileInputStream come_in=new FileInputStream("goods.txt")<br/>ObjectInputStream in =new ObjectInputStream(come_in)<br/>hashtable=(Hashtable)in.readObject()//// <br/>}

catch(ClassNotFoundException event){}

catch(IOException event){}

Enumeration enum=hashtable.elements()

while(enum.hasMoreElements())

{ 商品 te=(商品)enum.nextElement()

显示区.append("商品代号:"+te.代号+" ")

显示区.append("商品名称:"+te.名称+" ")

显示区.append("商品库存:"+te.库存+" ")

显示区.append("商品单价:"+te.单价+" ")

显示区.append("\n ")

}

}

}

}

public class LinkListFour

{public static void main(String args[]) <br/>{ ShowWin win=new ShowWin()<br/>win.setSize(400,350)<br/>win.setVisible(true)<br/>win.addWindowListener(new WindowAdapter() <br/>{public void windowClosing(WindowEvent e) <br/>{ System.exit(0)}})

}

}

终于完了! 追问: 这里面应该没有涉及到功能吧?? 回答: 你可以根据这个写出来呀!呵呵.

PrintService[] services = PrinterJob.lookupPrintServices()//查找系统中所有的可用打印服务

PrintService service = ServiceUI.printDialog(null, 500, 500, services, services[0], null, new HashPrintRequestAttributeSet())//创建一个默认的打印机选择对话框

DocPrintJob job = service.createPrintJob()//创建一个打印任务

Doc doc = new SimpleDoc(new FileInputStream(new File("D:\\image\\MM.jpg")), DocFlavor.INPUT_STREAM.JPEG, null)//创建一个打印的文档

job.print(doc, null)//打印

这是jdk提供的打印接口,你也可以找找其它的第三方类库,jdk提供打印接口功能一般般