olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r964747 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
Date Tue, 08 Sep 2015 11:53:49 GMT
Author: buildbot
Date: Tue Sep  8 11:53:49 2015
New Revision: 964747

Log:
Staging update by buildbot for olingo

Modified:
    websites/staging/olingo/trunk/content/   (props changed)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Sep  8 11:53:49 2015
@@ -1 +1 @@
-1701779
+1701780

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html Tue
Sep  8 11:53:49 2015
@@ -296,29 +296,30 @@ This method is been called if the curren
 </ul>
 <p>As you can see in this little example, it can be difficult to guess the right type.
In this tutorial we will focus on Edm.Int32. </p>
 <p>In real world scenarios, there is something called “numeric promotion”,
which converts numbers to the next higher type. <a href="http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398161">OData
Version 4.0 Part 2: URL Conventions Plus Errata 02</a></p>
-<div class="codehilite"><pre><span class="kd">public</span> <span
class="n">Object</span> <span class="nf">visitLiteral</span><span
class="o">(</span><span class="n">String</span> <span class="n">literal</span><span
class="o">)</span> <span class="kd">throws</span> <span class="n">ExpressionVisitException</span><span
class="o">,</span> 
-                                                    <span class="n">ODataApplicationException</span>
<span class="o">{</span>
+<div class="codehilite"><pre><span class="nd">@Override</span>
+<span class="kd">public</span> <span class="n">Object</span> <span
class="nf">visitLiteral</span><span class="o">(</span><span class="n">Literal</span>
<span class="n">literal</span><span class="o">)</span> <span class="kd">throws</span>
<span class="n">ExpressionVisitException</span><span class="o">,</span>
<span class="n">ODataApplicationException</span> <span class="o">{</span>
     <span class="c1">// To keep this tutorial simple, our filter expression visitor
supports only Edm.Int32 and Edm.String</span>
     <span class="c1">// In real world scenarios it can be difficult to guess the type
of an literal.</span>
     <span class="c1">// We can be sure, that the literal is a valid OData literal because
the URI Parser checks </span>
     <span class="c1">// the lexicographical structure</span>
 
     <span class="c1">// String literals start and end with an single quotation mark</span>
-    <span class="k">if</span><span class="o">(</span><span class="n">literal</span><span
class="o">.</span><span class="na">startsWith</span><span class="o">(</span><span
class="s">&quot;&#39;&quot;</span><span class="o">)</span>
<span class="o">&amp;&amp;</span> <span class="n">literal</span><span
class="o">.</span><span class="na">endsWith</span><span class="o">(</span><span
class="s">&quot;&#39;&quot;</span><span class="o">))</span>
<span class="o">{</span>
-      <span class="n">String</span> <span class="n">stringLiteral</span>
<span class="o">=</span> <span class="s">&quot;&quot;</span><span
class="o">;</span>
-      <span class="k">if</span><span class="o">(</span><span class="n">literal</span><span
class="o">.</span><span class="na">length</span><span class="o">()</span>
<span class="o">&gt;</span> <span class="mi">2</span><span
class="o">)</span> <span class="o">{</span>
-        <span class="n">stringLiteral</span> <span class="o">=</span>
<span class="n">literal</span><span class="o">.</span><span class="na">substring</span><span
class="o">(</span><span class="mi">1</span><span class="o">,</span>
<span class="n">literal</span><span class="o">.</span><span class="na">length</span><span
class="o">()</span> <span class="o">-</span> <span class="mi">1</span><span
class="o">);</span>
-      <span class="o">}</span>
+    <span class="n">String</span> <span class="n">literalAsString</span>
<span class="o">=</span> <span class="n">literal</span><span class="o">.</span><span
class="na">getText</span><span class="o">();</span>
+    <span class="k">if</span><span class="o">(</span><span class="n">literal</span><span
class="o">.</span><span class="na">getType</span><span class="o">()</span>
<span class="k">instanceof</span> <span class="n">EdmString</span><span
class="o">)</span> <span class="o">{</span>
+        <span class="n">String</span> <span class="n">stringLiteral</span>
<span class="o">=</span> <span class="s">&quot;&quot;</span><span
class="o">;</span>
+        <span class="k">if</span><span class="o">(</span><span
class="n">literal</span><span class="o">.</span><span class="na">getText</span><span
class="o">().</span><span class="na">length</span><span class="o">()</span>
<span class="o">&gt;</span> <span class="mi">2</span><span
class="o">)</span> <span class="o">{</span>
+            <span class="n">stringLiteral</span> <span class="o">=</span>
<span class="n">literalAsString</span><span class="o">.</span><span
class="na">substring</span><span class="o">(</span><span class="mi">1</span><span
class="o">,</span> <span class="n">literalAsString</span><span class="o">.</span><span
class="na">length</span><span class="o">()</span> <span class="o">-</span>
<span class="mi">1</span><span class="o">);</span>
+        <span class="o">}</span>
 
-      <span class="k">return</span> <span class="n">stringLiteral</span><span
class="o">;</span>
+        <span class="k">return</span> <span class="n">stringLiteral</span><span
class="o">;</span>
     <span class="o">}</span> <span class="k">else</span> <span
class="o">{</span>
-      <span class="c1">// Try to convert the literal into an Java Integer</span>
-      <span class="k">try</span> <span class="o">{</span>
-        <span class="k">return</span> <span class="n">Integer</span><span
class="o">.</span><span class="na">parseInt</span><span class="o">(</span><span
class="n">literal</span><span class="o">);</span>
-      <span class="o">}</span> <span class="k">catch</span><span
class="o">(</span><span class="n">NumberFormatException</span> <span
class="n">e</span><span class="o">)</span> <span class="o">{</span>
-        <span class="k">throw</span> <span class="k">new</span> <span
class="nf">ODataApplicationException</span><span class="o">(</span><span
class="s">&quot;Only Edm.Int32 and Edm.String literals are </span>
-<span class="s">             implemented&quot;</span><span class="o">,</span>
<span class="n">HttpStatusCode</span><span class="o">.</span><span
class="na">NOT_IMPLEMENTED</span><span class="o">.</span><span class="na">getStatusCode</span><span
class="o">(),</span> <span class="n">Locale</span><span class="o">.</span><span
class="na">ENGLISH</span><span class="o">);</span>
-      <span class="o">}</span>
+        <span class="c1">// Try to convert the literal into an Java Integer</span>
+        <span class="k">try</span> <span class="o">{</span>
+            <span class="k">return</span> <span class="n">Integer</span><span
class="o">.</span><span class="na">parseInt</span><span class="o">(</span><span
class="n">literalAsString</span><span class="o">);</span>
+        <span class="o">}</span> <span class="k">catch</span><span
class="o">(</span><span class="n">NumberFormatException</span> <span
class="n">e</span><span class="o">)</span> <span class="o">{</span>
+            <span class="k">throw</span> <span class="k">new</span>
<span class="nf">ODataApplicationException</span><span class="o">(</span><span
class="s">&quot;Only Edm.Int32 and Edm.String literals are implemented&quot;</span><span
class="o">,</span> 
+                <span class="n">HttpStatusCode</span><span class="o">.</span><span
class="na">NOT_IMPLEMENTED</span><span class="o">.</span><span class="na">getStatusCode</span><span
class="o">(),</span> <span class="n">Locale</span><span class="o">.</span><span
class="na">ENGLISH</span><span class="o">);</span>
+        <span class="o">}</span>
     <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>



Mime
View raw message