-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33178 from vespa-engine/bratseth/to_uri
Add to_uri as prophesied in the documentation
- Loading branch information
Showing
5 changed files
with
129 additions
and
38 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...glanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/ToUriExpression.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,53 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
package com.yahoo.vespa.indexinglanguage.expressions; | ||
|
||
import com.yahoo.document.DataType; | ||
import com.yahoo.document.datatypes.StringFieldValue; | ||
import com.yahoo.document.datatypes.UriFieldValue; | ||
|
||
/** | ||
* @author bratseth | ||
*/ | ||
public final class ToUriExpression extends Expression { | ||
|
||
@Override | ||
public DataType setInputType(DataType input, VerificationContext context) { | ||
super.setInputType(input, context); | ||
return DataType.URI; | ||
} | ||
|
||
@Override | ||
public DataType setOutputType(DataType output, VerificationContext context) { | ||
super.setOutputType(DataType.URI, output, null, context); | ||
return getInputType(context); | ||
} | ||
|
||
@Override | ||
protected void doVerify(VerificationContext context) { | ||
if (context.getCurrentType() == null) | ||
throw new VerificationException(this, "Expected input, but no input is provided"); | ||
context.setCurrentType(createdOutputType()); | ||
} | ||
|
||
@Override | ||
protected void doExecute(ExecutionContext context) { | ||
context.setCurrentValue(new UriFieldValue(String.valueOf(context.getCurrentValue()))); | ||
} | ||
|
||
@Override | ||
public DataType createdOutputType() { return DataType.URI; } | ||
|
||
@Override | ||
public String toString() { return "to_uri"; } | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return obj instanceof ToUriExpression; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getClass().hashCode(); | ||
} | ||
|
||
} |
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
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