-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/ortus-solutions-priv…
…ate/boxlang into development
- Loading branch information
Showing
18 changed files
with
1,104 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/ortus/boxlang/runtime/bifs/global/query/QueryGetResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* [BoxLang] | ||
* | ||
* Copyright [2023] [Ortus Solutions, Corp] | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ortus.boxlang.runtime.bifs.global.query; | ||
|
||
import ortus.boxlang.runtime.bifs.BIF; | ||
import ortus.boxlang.runtime.bifs.BoxBIF; | ||
import ortus.boxlang.runtime.bifs.BoxMember; | ||
import ortus.boxlang.runtime.context.IBoxContext; | ||
import ortus.boxlang.runtime.scopes.ArgumentsScope; | ||
import ortus.boxlang.runtime.scopes.Key; | ||
import ortus.boxlang.runtime.types.Argument; | ||
import ortus.boxlang.runtime.types.BoxLangType; | ||
import ortus.boxlang.runtime.types.Query; | ||
|
||
@BoxBIF | ||
@BoxMember( type = BoxLangType.QUERY ) | ||
public class QueryGetResult extends BIF { | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public QueryGetResult() { | ||
super(); | ||
declaredArguments = new Argument[] { | ||
new Argument( true, "query", Key.query ) | ||
}; | ||
} | ||
|
||
/** | ||
* Returns the metadata of a query. | ||
* | ||
* | ||
* @param context The context in which the BIF is being invoked. | ||
* @param arguments Argument scope for the BIF. | ||
* | ||
* @argument.query The query to get the result from | ||
*/ | ||
public Object _invoke( IBoxContext context, ArgumentsScope arguments ) { | ||
Query query = arguments.getAsQuery( Key.query ); | ||
|
||
return query.getMetaData(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/main/java/ortus/boxlang/runtime/bifs/global/xml/XMLElemNew.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
|
||
/** | ||
* [BoxLang] | ||
* | ||
* Copyright [2023] [Ortus Solutions, Corp] | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 ortus.boxlang.runtime.bifs.global.xml; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
|
||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Node; | ||
import org.xml.sax.InputSource; | ||
import org.xml.sax.SAXException; | ||
|
||
import ortus.boxlang.runtime.bifs.BIF; | ||
import ortus.boxlang.runtime.bifs.BoxBIF; | ||
import ortus.boxlang.runtime.context.IBoxContext; | ||
import ortus.boxlang.runtime.scopes.ArgumentsScope; | ||
import ortus.boxlang.runtime.scopes.Key; | ||
import ortus.boxlang.runtime.types.Argument; | ||
import ortus.boxlang.runtime.types.XML; | ||
import ortus.boxlang.runtime.types.exceptions.BoxRuntimeException; | ||
|
||
@BoxBIF | ||
public class XMLElemNew extends BIF { | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public XMLElemNew() { | ||
super(); | ||
declaredArguments = new Argument[] { | ||
new Argument( true, "xml", Key.XML ), | ||
new Argument( true, "string", Key.childname ), | ||
new Argument( false, "string", Key.namespace ) | ||
}; | ||
} | ||
|
||
/** | ||
* Creates a new XML Element which can be appended to an XML document | ||
* | ||
* @param context The context in which the BIF is being invoked. | ||
* @param arguments Argument scope for the BIF. | ||
* | ||
* @argument.xml The parent XML object to associate the new node to | ||
* | ||
* @argument.childName The XML name of the new child node | ||
* | ||
* @argument.namespace The XML namespace to attach to the new child node | ||
*/ | ||
public Object _invoke( IBoxContext context, ArgumentsScope arguments ) { | ||
XML xmlObject = arguments.getAsXML( Key.XML ); | ||
String childName = arguments.getAsString( Key.childname ); | ||
String namespace = arguments.getAsString( Key.namespace ); | ||
|
||
Node documentNode = xmlObject.getNode(); | ||
|
||
if ( documentNode == null ) { | ||
String xmlString = null; | ||
try { | ||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); | ||
|
||
if ( namespace != null ) { | ||
xmlString = "<" + childName + " xmlns=\"" + namespace + "\"/>"; | ||
} else { | ||
xmlString = "<" + childName + "/>"; | ||
} | ||
|
||
return builder.parse( new InputSource( new StringReader( xmlString ) ) ); | ||
|
||
} catch ( ParserConfigurationException e ) { | ||
throw new BoxRuntimeException( "Error creating XML parser", e ); | ||
} catch ( SAXException e ) { | ||
throw new BoxRuntimeException( "Error parsing XML elemement" + xmlString, e ); | ||
} catch ( IOException e ) { | ||
throw new BoxRuntimeException( "Error parsing XML element" + xmlString, e ); | ||
} | ||
} else if ( namespace != null ) { | ||
Document ownerDocument = documentNode.getOwnerDocument() == null ? ( Document ) documentNode : documentNode.getOwnerDocument(); | ||
return ownerDocument.createElementNS( namespace, childName ); | ||
} else { | ||
Document ownerDocument = documentNode.getOwnerDocument() == null ? ( Document ) documentNode : documentNode.getOwnerDocument(); | ||
return ownerDocument.createElement( childName ); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.