Mercurial > hg > release > icedtea6-1.10
changeset 1591:852af6e8bf0e
2009-06-09 Omair Majid <omajid@redhat.com>
* rt/net/sourceforge/jnlp/AssociationDesc.java: New file.
(AssociationDesc): New function. Create an association descriptor.
(getExtensions): New function. Get the extensions for this association.
(getMimeType): New function. Get the mimetype for this association.
(checkMimeType): New function.
* rt/net/sourceforge/jnlp/InformationDesc.java
(getAssociations): New function. Get the associations.
(getShortcut): New function. Get the shortcut.
(getRelatedContents): New function. Get the related-contents.
* rt/net/sourceforge/jnlp/MenuDesc.java: New file.
(MenuDesc): New function.
(getSubMenu): New function. Get the submenu for this menu descriptor.
* rt/net/sourceforge/jnlp/Parser.java
(getInformationDesc): Parse "assocation", "shortcut" and
"related-content" elements.
(getAssociation): New function. Parse the association node to create a
AssociationDesc.
(getShortcut): New function. Parse the shortcut node to create a
ShortcutDesc.
(getMenu): New function. Parse a menu node to create a MenuDesc.
(getRelatedContent): New function. Parse a related-content node to create a
RelatedContentDesc.
* rt/net/sourceforge/jnlp/RelatedContentDesc.java
(RelatedContentDesc): New function.
(setTitle): New function. Set the title of this content.
(getTitle): New function. Get the title of this content.
(setDescription): New function. Set the description of this content.
(getDescription): New function. Get the description of this content.
(getLocation): New function. Get the location of this content.
(setIconDesc): New function. Set the icon descriptor for this content.
(getIcon): Get the icon descriptor for this content.
* rt/net/sourceforge/jnlp/ShortcutDesc.java
(ShortcutDesc): New function. Initialize requiresOnline and onDesktop.
(isOnline): New function. Return true if the shortcut is online only.
(onDesktop): New function. Return true if the shortcut should be placed on
the desktop.
(addMenu): New function. Add a menu descriptor for this shortcut.
(getMenu): New function. Return the menu descriptor for this shortcut.
* rt/net/sourceforge/jnlp/resources/Messages.properties:
Add PTwoDesktops, PTwoMenus, PTwoTitle and PTwoIcons.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 09 Jun 2009 14:08:52 -0400 |
parents | ff13b7d6e330 |
children | 188882817ac2 |
files | ChangeLog rt/net/sourceforge/jnlp/AssociationDesc.java rt/net/sourceforge/jnlp/InformationDesc.java rt/net/sourceforge/jnlp/MenuDesc.java rt/net/sourceforge/jnlp/Parser.java rt/net/sourceforge/jnlp/RelatedContentDesc.java rt/net/sourceforge/jnlp/ShortcutDesc.java rt/net/sourceforge/jnlp/resources/Messages.properties |
diffstat | 8 files changed, 445 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jun 09 08:53:57 2009 -0400 +++ b/ChangeLog Tue Jun 09 14:08:52 2009 -0400 @@ -1,3 +1,46 @@ +2009-06-09 Omair Majid <omajid@redhat.com> + + * rt/net/sourceforge/jnlp/AssociationDesc.java: New file. + (AssociationDesc): New function. Create an association descriptor. + (getExtensions): New function. Get the extensions for this association. + (getMimeType): New function. Get the mimetype for this association. + (checkMimeType): New function. + * rt/net/sourceforge/jnlp/InformationDesc.java + (getAssociations): New function. Get the associations. + (getShortcut): New function. Get the shortcut. + (getRelatedContents): New function. Get the related-contents. + * rt/net/sourceforge/jnlp/MenuDesc.java: New file. + (MenuDesc): New function. + (getSubMenu): New function. Get the submenu for this menu descriptor. + * rt/net/sourceforge/jnlp/Parser.java + (getInformationDesc): Parse "assocation", "shortcut" and + "related-content" elements. + (getAssociation): New function. Parse the association node to create a + AssociationDesc. + (getShortcut): New function. Parse the shortcut node to create a + ShortcutDesc. + (getMenu): New function. Parse a menu node to create a MenuDesc. + (getRelatedContent): New function. Parse a related-content node to create a + RelatedContentDesc. + * rt/net/sourceforge/jnlp/RelatedContentDesc.java + (RelatedContentDesc): New function. + (setTitle): New function. Set the title of this content. + (getTitle): New function. Get the title of this content. + (setDescription): New function. Set the description of this content. + (getDescription): New function. Get the description of this content. + (getLocation): New function. Get the location of this content. + (setIconDesc): New function. Set the icon descriptor for this content. + (getIcon): Get the icon descriptor for this content. + * rt/net/sourceforge/jnlp/ShortcutDesc.java + (ShortcutDesc): New function. Initialize requiresOnline and onDesktop. + (isOnline): New function. Return true if the shortcut is online only. + (onDesktop): New function. Return true if the shortcut should be placed on + the desktop. + (addMenu): New function. Add a menu descriptor for this shortcut. + (getMenu): New function. Return the menu descriptor for this shortcut. + * rt/net/sourceforge/jnlp/resources/Messages.properties: + Add PTwoDesktops, PTwoMenus, PTwoTitle and PTwoIcons. + 2009-06-09 Gary Benson <gbenson@redhat.com> * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/net/sourceforge/jnlp/AssociationDesc.java Tue Jun 09 14:08:52 2009 -0400 @@ -0,0 +1,56 @@ +// Copyright (C) 2009 Red Hat, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package net.sourceforge.jnlp; + +public final class AssociationDesc { + + /** the extensions this application wants to register with */ + private String[] extensions; + + /** the mime type for the association */ + private String mimeType; + + public AssociationDesc(String mimeType, String[] extensions) throws ParseException { + checkMimeType(mimeType); + this.mimeType = mimeType; + this.extensions = extensions; + } + + /** + * Return the extensions for this association + */ + public String[] getExtensions() { + return extensions; + } + + /** + * Return the mimetype for this association + */ + public String getMimeType() { + return mimeType; + } + + /** + * Check for valid mimeType + * @param mimeType a mime type + * @throws ParseException if mimeType is an invalid MIME type + */ + private void checkMimeType(String mimeType) throws ParseException { + // TODO check that mime type is valid + } + +}
--- a/rt/net/sourceforge/jnlp/InformationDesc.java Tue Jun 09 08:53:57 2009 -0400 +++ b/rt/net/sourceforge/jnlp/InformationDesc.java Tue Jun 09 14:08:52 2009 -0400 @@ -1,4 +1,5 @@ // Copyright (C) 2001-2003 Jon A. Maxwell (JAM) +// Copyright (C) 2009 Red Hat, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -200,6 +201,32 @@ } /** + * Returns the associations specified in the JNLP file + */ + public AssociationDesc[] getAssociations() { + List associations = getItems("association"); + + return (AssociationDesc[]) associations.toArray(new AssociationDesc[associations.size()]); + } + + /** + * Returns the shortcut specified by this JNLP file + */ + public ShortcutDesc getShortcut() { + return (ShortcutDesc) getItem("shortcut"); + } + + /** + * Returns the related-contents specified by this JNLP file + */ + public RelatedContentDesc[] getRelatedContents() { + List relatedContents = getItems("related-content"); + + return (RelatedContentDesc[]) relatedContents.toArray( + new RelatedContentDesc[relatedContents.size()]); + } + + /** * Returns the last item matching the specified key. */ protected Object getItem(Object key) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/net/sourceforge/jnlp/MenuDesc.java Tue Jun 09 14:08:52 2009 -0400 @@ -0,0 +1,38 @@ +// Copyright (C) 2009 Red Hat, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package net.sourceforge.jnlp; + +public class MenuDesc { + + /** the submenu for this menu entry */ + private String subMenu; + + /** + * Create a new menu descriptor + */ + public MenuDesc(String subMenu) { + this.subMenu = subMenu; + } + + /** + * Returns the submenu for this menu entry. + */ + public String getSubMenu() { + return subMenu; + } + +}
--- a/rt/net/sourceforge/jnlp/Parser.java Tue Jun 09 08:53:57 2009 -0400 +++ b/rt/net/sourceforge/jnlp/Parser.java Tue Jun 09 14:08:52 2009 -0400 @@ -1,4 +1,5 @@ // Copyright (C) 2001-2003 Jon A. Maxwell (JAM) +// Copyright (C) 2009 Red Hat, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -435,6 +436,15 @@ throw new ParseException(R("PSharing")); addInfo(info, child, null, Boolean.TRUE); } + if ("association".equals(name)) { + addInfo(info, child, null, getAssociation(child)); + } + if ("shortcut".equals(name)) { + addInfo(info, child, null, getShortcut(child)); + } + if ("related-content".equals(name)) { + addInfo(info, child, null, getRelatedContent(child)); + } child = child.getNextSibling(); } @@ -643,6 +653,110 @@ return new InstallerDesc(main); } + /** + * Returns the association descriptor. + */ + public AssociationDesc getAssociation(Node node) throws ParseException { + String[] extensions = getRequiredAttribute(node, "extensions", null).split(" "); + String mimeType = getRequiredAttribute(node, "mime-type", null); + + return new AssociationDesc(mimeType, extensions); + } + + /** + * Returns the shortcut descriptor. + */ + public ShortcutDesc getShortcut(Node node) throws ParseException { + + String online = getAttribute(node, "online", "true"); + boolean shortcutIsOnline = Boolean.valueOf(online); + + boolean showOnDesktop = false; + MenuDesc menu = null; + + // step through the elements + Node child = node.getFirstChild(); + while (child != null) { + String name = child.getNodeName(); + + if ("desktop".equals(name)) { + if (showOnDesktop && strict) { + throw new ParseException(R("PTwoDesktops")); + } + showOnDesktop = true; + } else if ("menu".equals(name)){ + if (menu != null && strict) { + throw new ParseException(R("PTwoMenus")); + } + menu = getMenu(child); + } + + child = child.getNextSibling(); + } + + ShortcutDesc shortcut = new ShortcutDesc(shortcutIsOnline, showOnDesktop); + if (menu != null) { + shortcut.addMenu(menu); + } + return shortcut; + } + + /** + * Returns the menu descriptor. + */ + public MenuDesc getMenu(Node node) { + String subMenu = getAttribute(node, "submenu", null); + + return new MenuDesc(subMenu); + } + + + /** + * Returns the related-content descriptor. + */ + public RelatedContentDesc getRelatedContent(Node node) throws ParseException { + + getRequiredAttribute(node, "href", null); + URL location = getURL(node, "href", base); + + String title = null; + String description = null; + IconDesc icon = null; + + // step through the elements + Node child = node.getFirstChild(); + while (child != null) { + String name = child.getNodeName(); + + if ("title".equals(name)) { + if (title != null && strict) { + throw new ParseException(R("PTwoTitles")); + } + title = getSpanText(child); + } else if ("description".equals(name)) { + if (description != null && strict) { + throw new ParseException(R("PTwoDescriptions")); + } + description = getSpanText(child); + } else if ("icon".equals(name)) { + if (icon != null && strict) { + throw new ParseException(R("PTwoIcons")); + } + icon = getIcon(child); + } + + child = child.getNextSibling(); + } + + RelatedContentDesc relatedContent = new RelatedContentDesc(location); + relatedContent.setDescription(description); + relatedContent.setIconDesc(icon); + relatedContent.setTitle(title); + + return relatedContent; + + } + // other methods /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/net/sourceforge/jnlp/RelatedContentDesc.java Tue Jun 09 14:08:52 2009 -0400 @@ -0,0 +1,93 @@ +// Copyright (C) 2009 Red Hat, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package net.sourceforge.jnlp; + +import java.net.URL; + +public class RelatedContentDesc { + + /** title of the content */ + private String title = null;; + + /** the description of the content */ + private String description = null; + + /** the location of the content */ + private URL location = null; + + /** the icon for this related content */ + private IconDesc icon = null; + + /** + * Create a related-content descriptor + * @param href the url of the related content + */ + public RelatedContentDesc(URL href) { + this.location = href; + } + + /** + * Set the title of this content + * @param title the title of this content + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Returns the title of this content.. + */ + public String getTitle() { + return title; + } + + /** + * Set the description of this related content + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the description of the related content + */ + public String getDescription() { + return description; + } + + /** + * Returns the location of the related content. Not null + */ + public URL getLocation() { + return location; + } + + /** + * Set the icon for this related content + */ + public void setIconDesc(IconDesc icon) { + this.icon = icon; + } + + /** + * Returns the icon descriptor for the realted content + */ + public IconDesc getIcon() { + return icon; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/net/sourceforge/jnlp/ShortcutDesc.java Tue Jun 09 14:08:52 2009 -0400 @@ -0,0 +1,70 @@ +// Copyright (C) 2009 Red Hat, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package net.sourceforge.jnlp; + +public final class ShortcutDesc { + + /** the application wants to be placed on the desktop */ + private boolean onDesktop = false; + + /** the application needs to be launched online */ + private boolean requiresOnline = true; + + /** the menu descriptor */ + private MenuDesc menu = null; + + /** + * Create a new Shortcut descriptor + * @param requiresOnline whether the shortcut requires connectivity + * @param onDesktop whether the shortcut wants to be placed on the desktop + */ + public ShortcutDesc(boolean requiresOnline, boolean onDesktop) { + this.requiresOnline = requiresOnline; + this.onDesktop = onDesktop; + } + + /** + * Returns whether the shortcut requires being online + */ + public boolean isOnline() { + return requiresOnline; + } + + /** + * Return whether the shortcut should be placed on the desktop + */ + public boolean onDesktop() { + return onDesktop; + } + + /** + * Add a shortcut to the 'start menu' + * (whatever that means on gnome/kde/other ...) + * @param menu if/what menu this shortcut should be added to + */ + public void addMenu(MenuDesc menu) { + this.menu = menu; + } + + /** + * Returns the menu this shortcut should be added to + */ + public MenuDesc getMenu() { + return menu; + } + +}
--- a/rt/net/sourceforge/jnlp/resources/Messages.properties Tue Jun 09 08:53:57 2009 -0400 +++ b/rt/net/sourceforge/jnlp/resources/Messages.properties Tue Jun 09 14:08:52 2009 -0400 @@ -80,6 +80,10 @@ PTwoSecurity=Only one security element allowed per JNLPFile. PEmptySecurity=Security element specified but does not contain a permissions element. PTwoDescriptors=Only one application descriptor element allowed per JNLPFile. +PTwoDesktops=Only one desktop element allowed +PTwoMenus=Only one menu element allowed +PTwoTitles=Only one title element allowed +PTwoIcons=Only one icon element allowed PUnknownApplet=Unknown Applet PBadWidth=Invalid applet width. PBadHeight=Invalid applet height.