-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial support for parsing XML namespaces #3925
Changes from 23 commits
512d05e
7b65a68
9d4c924
520a282
1ec44eb
f5a3621
aecc3e6
385cb7b
c88e2ae
546b99f
5d2e2b8
e0e9527
436049d
f621398
218827b
a456198
b283aa0
5c76231
d1cffc1
acb7c26
6fec0b5
bf3b658
ac084a1
326b824
50dc26f
20e6212
69d6772
527a239
2a0212b
cd2fcf3
c7f84cc
e4083b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openrewrite.xml.internal; | ||
|
||
import lombok.Value; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@Value | ||
public class Namespaces { | ||
|
||
Map<String, String> namespaces = new HashMap<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A mutable map here might lead to problems with our immutability convention and detecting changes. |
||
|
||
public Namespaces() { | ||
} | ||
|
||
public Namespaces(String prefix, String uri) { | ||
add(prefix, uri); | ||
} | ||
|
||
public Namespaces add(String prefix, String uri) { | ||
namespaces.put(prefix, uri); | ||
return this; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public Namespaces combine(Namespaces namespaces) { | ||
this.namespaces.putAll(namespaces.getNamespaces()); | ||
return this; | ||
} | ||
|
||
public String get(String prefix) { | ||
return namespaces.get(prefix); | ||
} | ||
|
||
public boolean containsPrefix(String prefix) { | ||
return namespaces.containsKey(prefix); | ||
} | ||
|
||
public boolean containsUri(String uri) { | ||
return namespaces.containsValue(uri); | ||
} | ||
|
||
public Set<Map.Entry<String, String>> entrySet() { | ||
return namespaces.entrySet(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is returned from tree.Xml perhaps we should not have this class in an internal package?