diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java | 94 |
1 files changed, 53 insertions, 41 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java index febdb92091..4c652e583d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java @@ -183,54 +183,61 @@ public class ManifestParser extends DefaultHandler { } /** {@inheritDoc} */ + @SuppressWarnings("nls") @Override public void startElement( String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("project".equals(qName)) { //$NON-NLS-1$ - if (attributes.getValue("name") == null) { //$NON-NLS-1$ + if (qName == null) { + return; + } + switch (qName) { + case "project": + if (attributes.getValue("name") == null) { throw new SAXException(RepoText.get().invalidManifest); } - currentProject = new RepoProject( - attributes.getValue("name"), //$NON-NLS-1$ - attributes.getValue("path"), //$NON-NLS-1$ - attributes.getValue("revision"), //$NON-NLS-1$ - attributes.getValue("remote"), //$NON-NLS-1$ - attributes.getValue("groups")); //$NON-NLS-1$ - currentProject.setRecommendShallow( - attributes.getValue("clone-depth")); //$NON-NLS-1$ - } else if ("remote".equals(qName)) { //$NON-NLS-1$ - String alias = attributes.getValue("alias"); //$NON-NLS-1$ - String fetch = attributes.getValue("fetch"); //$NON-NLS-1$ - String revision = attributes.getValue("revision"); //$NON-NLS-1$ + currentProject = new RepoProject(attributes.getValue("name"), + attributes.getValue("path"), + attributes.getValue("revision"), + attributes.getValue("remote"), + attributes.getValue("groups")); + currentProject + .setRecommendShallow(attributes.getValue("clone-depth")); + break; + case "remote": + String alias = attributes.getValue("alias"); + String fetch = attributes.getValue("fetch"); + String revision = attributes.getValue("revision"); Remote remote = new Remote(fetch, revision); - remotes.put(attributes.getValue("name"), remote); //$NON-NLS-1$ - if (alias != null) + remotes.put(attributes.getValue("name"), remote); + if (alias != null) { remotes.put(alias, remote); - } else if ("default".equals(qName)) { //$NON-NLS-1$ - defaultRemote = attributes.getValue("remote"); //$NON-NLS-1$ - defaultRevision = attributes.getValue("revision"); //$NON-NLS-1$ - } else if ("copyfile".equals(qName)) { //$NON-NLS-1$ - if (currentProject == null) + } + break; + case "default": + defaultRemote = attributes.getValue("remote"); + defaultRevision = attributes.getValue("revision"); + break; + case "copyfile": + if (currentProject == null) { throw new SAXException(RepoText.get().invalidManifest); - currentProject.addCopyFile(new CopyFile( - rootRepo, - currentProject.getPath(), - attributes.getValue("src"), //$NON-NLS-1$ - attributes.getValue("dest"))); //$NON-NLS-1$ - } else if ("linkfile".equals(qName)) { //$NON-NLS-1$ + } + currentProject.addCopyFile(new CopyFile(rootRepo, + currentProject.getPath(), attributes.getValue("src"), + attributes.getValue("dest"))); + break; + case "linkfile": if (currentProject == null) { throw new SAXException(RepoText.get().invalidManifest); } - currentProject.addLinkFile(new LinkFile( - rootRepo, - currentProject.getPath(), - attributes.getValue("src"), //$NON-NLS-1$ - attributes.getValue("dest"))); //$NON-NLS-1$ - } else if ("include".equals(qName)) { //$NON-NLS-1$ - String name = attributes.getValue("name"); //$NON-NLS-1$ + currentProject.addLinkFile(new LinkFile(rootRepo, + currentProject.getPath(), attributes.getValue("src"), + attributes.getValue("dest"))); + break; + case "include": + String name = attributes.getValue("name"); if (includedReader != null) { try (InputStream is = includedReader.readIncludeFile(name)) { if (is == null) { @@ -239,8 +246,8 @@ public class ManifestParser extends DefaultHandler { } read(is); } catch (Exception e) { - throw new SAXException(MessageFormat.format( - RepoText.get().errorIncludeFile, name), e); + throw new SAXException(MessageFormat + .format(RepoText.get().errorIncludeFile, name), e); } } else if (filename != null) { int index = filename.lastIndexOf('/'); @@ -248,13 +255,18 @@ public class ManifestParser extends DefaultHandler { try (InputStream is = new FileInputStream(path)) { read(is); } catch (IOException e) { - throw new SAXException(MessageFormat.format( - RepoText.get().errorIncludeFile, path), e); + throw new SAXException(MessageFormat + .format(RepoText.get().errorIncludeFile, path), e); } } - } else if ("remove-project".equals(qName)) { //$NON-NLS-1$ - String name = attributes.getValue("name"); //$NON-NLS-1$ - projects.removeIf((p) -> p.getName().equals(name)); + break; + case "remove-project": { + String name2 = attributes.getValue("name"); + projects.removeIf((p) -> p.getName().equals(name2)); + break; + } + default: + break; } } |