code
stringlengths
4
991k
repo_name
stringlengths
6
116
path
stringlengths
4
249
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
4
991k
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #include <math.h> #include "vec3.h" #include "common.h" #include "solid_vary.h" #include "solid_sim.h" #include "solid_all.h" #include "solid_cmd.h" #define LARGE 1.0e+5f #define SMALL 1.0e-3f /*---------------------------------------------------------------------------*/ /* Solves (p + v * t) . (p + v * t) == r * r for smallest t. */ /* * Given vectors A = P, B = V * t, C = A + B, |C| = r, solve for * smallest t. * * Some useful dot product properties: * * 1) A . A = |A| * |A| * 2) A . (B + C) = A . B + A . C * 3) (r * A) . B = r * (A . B) * * Deriving a quadratic equation: * * C . C = r * r (1) * (A + B) . (A + B) = r * r * A . (A + B) + B . (A + B) = r * r (2) * A . A + A . B + B . A + B . B = r * r (2) * A . A + 2 * (A . B) + B . B = r * r * P . P + 2 * (P . V * t) + (V * t . V * t) = r * r * P . P + 2 * (P . V) * t + (V . V) * t * t = r * r (3) * (V . V) * t * t + 2 * (P . V) * t + P . P - r * r = 0 * * This equation is solved using the quadratic formula. */ static float v_sol(const float p[3], const float v[3], float r) { float a = v_dot(v, v); float b = v_dot(v, p) * 2.0f; float c = v_dot(p, p) - r * r; float d = b * b - 4.0f * a * c; /* HACK: This seems to cause failures to detect low-velocity collision Yet, the potential division by zero below seems fine. if (fabsf(a) < SMALL) return LARGE; */ if (d < 0.0f) return LARGE; else if (d > 0.0f) { float t0 = 0.5f * (-b - fsqrtf(d)) / a; float t1 = 0.5f * (-b + fsqrtf(d)) / a; float t = (t0 < t1) ? t0 : t1; return (t < 0.0f) ? LARGE : t; } else return -b * 0.5f / a; } /*---------------------------------------------------------------------------*/ /* * Compute the earliest time and position of the intersection of a * sphere and a vertex. * * The sphere has radius R and moves along vector V from point P. The * vertex moves along vector W from point Q in a coordinate system * based at O. */ static float v_vert(float Q[3], const float o[3], const float q[3], const float w[3], const float p[3], const float v[3], float r) { float O[3], P[3], V[3]; float t = LARGE; v_add(O, o, q); v_sub(P, p, O); v_sub(V, v, w); if (v_dot(P, V) < 0.0f) { t = v_sol(P, V, r); if (t < LARGE) v_mad(Q, O, w, t); } return t; } /* * Compute the earliest time and position of the intersection of a * sphere and an edge. * * The sphere has radius R and moves along vector V from point P. The * edge moves along vector W from point Q in a coordinate system based * at O. The edge extends along the length of vector U. */ static float v_edge(float Q[3], const float o[3], const float q[3], const float u[3], const float w[3], const float p[3], const float v[3], float r) { float d[3], e[3]; float P[3], V[3]; float du, eu, uu, s, t; v_sub(d, p, o); v_sub(d, d, q); v_sub(e, v, w); /* * Think projections. Vectors D, extending from the edge vertex Q * to the sphere, and E, the relative velocity of sphere wrt the * edge, are made orthogonal to the edge vector U. Division of * the dot products is required to obtain the true projection * ratios since U does not have unit length. */ du = v_dot(d, u); eu = v_dot(e, u); uu = v_dot(u, u); v_mad(P, d, u, -du / uu); /* First, test for intersection. */ if (v_dot(P, P) < r * r) { /* The sphere already intersects the line of the edge. */ if (du < 0 || du > uu) { /* * The sphere is behind the endpoints of the edge, and * can't hit the edge without hitting the vertices first. */ return LARGE; } /* The sphere already intersects the edge. */ if (v_dot(P, e) >= 0) { /* Moving apart. */ return LARGE; } v_nrm(P, P); v_mad(Q, p, P, -r); return 0; } v_mad(V, e, u, -eu / uu); t = v_sol(P, V, r); s = (du + eu * t) / uu; /* Projection of D + E * t on U. */ if (0.0f <= t && t < LARGE && 0.0f < s && s < 1.0f) { v_mad(d, o, w, t); v_mad(e, q, u, s); v_add(Q, e, d); } else t = LARGE; return t; } /* * Compute the earliest time and position of the intersection of a * sphere and a plane. * * The sphere has radius R and moves along vector V from point P. The * plane moves along vector W. The plane has normal N and is * positioned at distance D from the origin O along that normal. */ static float v_side(float Q[3], const float o[3], const float w[3], const float n[3], float d, const float p[3], const float v[3], float r) { float vn = v_dot(v, n); float wn = v_dot(w, n); float t = LARGE; if (vn - wn <= 0.0f) { float on = v_dot(o, n); float pn = v_dot(p, n); float u = (r + d + on - pn) / (vn - wn); float a = ( d + on - pn) / (vn - wn); if (0.0f <= u) { t = u; v_mad(Q, p, v, +t); v_mad(Q, Q, n, -r); } else if (0.0f <= a) { t = 0; v_mad(Q, p, v, +t); v_mad(Q, Q, n, -r); } } return t; } /*---------------------------------------------------------------------------*/ /* * Compute the new linear and angular velocities of a bouncing ball. * Q gives the position of the point of impact and W gives the * velocity of the object being impacted. */ static float sol_bounce(struct v_ball *up, const float q[3], const float w[3], float dt) { float n[3], r[3], d[3], vn, wn; float *p = up->p; float *v = up->v; /* Find the normal of the impact. */ v_sub(r, p, q); v_sub(d, v, w); v_nrm(n, r); /* Find the new angular velocity. */ v_crs(up->w, d, r); v_scl(up->w, up->w, -1.0f / (up->r * up->r)); /* Find the new linear velocity. */ vn = v_dot(v, n); wn = v_dot(w, n); v_mad(v, v, n, 1.7 * (wn - vn)); v_mad(p, q, n, up->r); /* Return the "energy" of the impact, to determine the sound amplitude. */ return fabsf(v_dot(n, d)); } /*---------------------------------------------------------------------------*/ static float sol_test_vert(float dt, float T[3], const struct v_ball *up, const struct b_vert *vp, const float o[3], const float w[3]) { return v_vert(T, o, vp->p, w, up->p, up->v, up->r); } static float sol_test_edge(float dt, float T[3], const struct v_ball *up, const struct s_base *base, const struct b_edge *ep, const float o[3], const float w[3]) { float q[3]; float u[3]; v_cpy(q, base->vv[ep->vi].p); v_sub(u, base->vv[ep->vj].p, base->vv[ep->vi].p); return v_edge(T, o, q, u, w, up->p, up->v, up->r); } static float sol_test_side(float dt, float T[3], const struct v_ball *up, const struct s_base *base, const struct b_lump *lp, const struct b_side *sp, const float o[3], const float w[3]) { float t = v_side(T, o, w, sp->n, sp->d, up->p, up->v, up->r); int i; if (t < dt) for (i = 0; i < lp->sc; i++) { const struct b_side *sq = base->sv + base->iv[lp->s0 + i]; if (sp != sq && v_dot(T, sq->n) - v_dot(o, sq->n) - v_dot(w, sq->n) * t > sq->d) return LARGE; } return t; } /*---------------------------------------------------------------------------*/ static int sol_test_fore(float dt, const struct v_ball *up, const struct b_side *sp, const float o[3], const float w[3]) { float q[3], d; /* If the ball is not behind the plane, the test passes. */ v_sub(q, up->p, o); d = sp->d; if (v_dot(q, sp->n) - d + up->r >= 0) return 1; /* If it's not behind the plane after DT seconds, the test passes. */ v_mad(q, q, up->v, dt); d += v_dot(w, sp->n) * dt; if (v_dot(q, sp->n) - d + up->r >= 0) return 1; /* Else, test fails. */ return 0; } static int sol_test_back(float dt, const struct v_ball *up, const struct b_side *sp, const float o[3], const float w[3]) { float q[3], d; /* If the ball is not in front of the plane, the test passes. */ v_sub(q, up->p, o); d = sp->d; if (v_dot(q, sp->n) - d - up->r <= 0) return 1; /* If it's not in front of the plane after DT seconds, the test passes. */ v_mad(q, q, up->v, dt); d += v_dot(w, sp->n) * dt; if (v_dot(q, sp->n) - d - up->r <= 0) return 1; /* Else, test fails. */ return 0; } /*---------------------------------------------------------------------------*/ static float sol_test_lump(float dt, float T[3], const struct v_ball *up, const struct s_base *base, const struct b_lump *lp, const float o[3], const float w[3]) { float U[3] = { 0.0f, 0.0f, 0.0f }; float u, t = dt; int i; /* Short circuit a non-solid lump. */ if (lp->fl & L_DETAIL) return t; /* Test all verts */ if (up->r > 0.0f) for (i = 0; i < lp->vc; i++) { const struct b_vert *vp = base->vv + base->iv[lp->v0 + i]; if ((u = sol_test_vert(t, U, up, vp, o, w)) < t) { v_cpy(T, U); t = u; } } /* Test all edges */ if (up->r > 0.0f) for (i = 0; i < lp->ec; i++) { const struct b_edge *ep = base->ev + base->iv[lp->e0 + i]; if ((u = sol_test_edge(t, U, up, base, ep, o, w)) < t) { v_cpy(T, U); t = u; } } /* Test all sides */ for (i = 0; i < lp->sc; i++) { const struct b_side *sp = base->sv + base->iv[lp->s0 + i]; if ((u = sol_test_side(t, U, up, base, lp, sp, o, w)) < t) { v_cpy(T, U); t = u; } } return t; } static float sol_test_node(float dt, float T[3], const struct v_ball *up, const struct s_base *base, const struct b_node *np, const float o[3], const float w[3]) { float U[3], u, t = dt; int i; /* Test all lumps */ for (i = 0; i < np->lc; i++) { const struct b_lump *lp = base->lv + np->l0 + i; if ((u = sol_test_lump(t, U, up, base, lp, o, w)) < t) { v_cpy(T, U); t = u; } } /* Test in front of this node */ if (np->ni >= 0 && sol_test_fore(t, up, base->sv + np->si, o, w)) { const struct b_node *nq = base->nv + np->ni; if ((u = sol_test_node(t, U, up, base, nq, o, w)) < t) { v_cpy(T, U); t = u; } } /* Test behind this node */ if (np->nj >= 0 && sol_test_back(t, up, base->sv + np->si, o, w)) { const struct b_node *nq = base->nv + np->nj; if ((u = sol_test_node(t, U, up, base, nq, o, w)) < t) { v_cpy(T, U); t = u; } } return t; } static float sol_test_body(float dt, float T[3], float V[3], const struct v_ball *up, const struct s_vary *vary, const struct v_body *bp) { float U[3], O[3], E[4], W[3], u; const struct b_node *np = vary->base->nv + bp->base->ni; sol_body_p(O, vary, bp, 0.0f); sol_body_v(W, vary, bp, dt); sol_body_e(E, vary, bp, 0.0f); /* * For rotating bodies, rather than rotate every normal and vertex * of the body, we temporarily pretend the ball is rotating and * moving about a static body. */ /* * Linear velocity of a point rotating about the origin: * v = w x p */ if (E[0] != 1.0f || sol_body_w(vary, bp)) { /* The body has a non-identity orientation or it is rotating. */ struct v_ball ball; float e[4], p0[3], p1[3]; const float z[3] = { 0 }; /* First, calculate position at start and end of time interval. */ v_sub(p0, up->p, O); v_cpy(p1, p0); q_conj(e, E); q_rot(p0, e, p0); v_mad(p1, p1, up->v, dt); v_mad(p1, p1, W, -dt); sol_body_e(e, vary, bp, dt); q_conj(e, e); q_rot(p1, e, p1); /* Set up ball struct with values relative to body. */ ball = *up; v_cpy(ball.p, p0); /* Calculate velocity from start/end positions and time. */ v_sub(ball.v, p1, p0); v_scl(ball.v, ball.v, 1.0f / dt); if ((u = sol_test_node(dt, U, &ball, vary->base, np, z, z)) < dt) { /* Compute the final orientation. */ sol_body_e(e, vary, bp, u); /* Return world space coordinates. */ q_rot(T, e, U); v_add(T, O, T); /* Move forward. */ v_mad(T, T, W, u); /* Express "non-ball" velocity. */ q_rot(V, e, ball.v); v_sub(V, up->v, V); dt = u; } } else { if ((u = sol_test_node(dt, U, up, vary->base, np, O, W)) < dt) { v_cpy(T, U); v_cpy(V, W); dt = u; } } return dt; } static float sol_test_file(float dt, float T[3], float V[3], const struct v_ball *up, const struct s_vary *vary) { float U[3], W[3], u, t = dt; int i; for (i = 0; i < vary->bc; i++) { const struct v_body *bp = vary->bv + i; if ((u = sol_test_body(t, U, W, up, vary, bp)) < t) { v_cpy(T, U); v_cpy(V, W); t = u; } } return t; } /*---------------------------------------------------------------------------*/ /* * Track simulation steps in integer milliseconds. */ static float ms_accum; static void ms_init(void) { ms_accum = 0.0f; } static int ms_step(float dt) { int ms = 0; ms_accum += dt; while (ms_accum >= 0.001f) { ms_accum -= 0.001f; ms += 1; } return ms; } static int ms_peek(float dt) { int ms = 0; float at; at = ms_accum + dt; while (at >= 0.001f) { at -= 0.001f; ms += 1; } return ms; } /*---------------------------------------------------------------------------*/ /* * Step the physics forward DT seconds under the influence of gravity * vector G. If the ball gets pinched between two moving solids, this * loop might not terminate. It is better to do something physically * impossible than to lock up the game. So, if we make more than C * iterations, punt it. */ float sol_step(struct s_vary *vary, const float *g, float dt, int ui, int *m) { float P[3], V[3], v[3], r[3], a[3], d, e, nt, b = 0.0f, tt = dt; int c; union cmd cmd; if (ui < vary->uc) { struct v_ball *up = vary->uv + ui; /* If the ball is in contact with a surface, apply friction. */ v_cpy(a, up->v); v_cpy(v, up->v); v_cpy(up->v, g); if (m && sol_test_file(tt, P, V, up, vary) < 0.0005f) { v_cpy(up->v, v); v_sub(r, P, up->p); if ((d = v_dot(r, g) / (v_len(r) * v_len(g))) > 0.999f) { if ((e = (v_len(up->v) - dt)) > 0.0f) { /* Scale the linear velocity. */ v_nrm(up->v, up->v); v_scl(up->v, up->v, e); /* Scale the angular velocity. */ v_sub(v, V, up->v); v_crs(up->w, v, r); v_scl(up->w, up->w, -1.0f / (up->r * up->r)); } else { /* Friction has brought the ball to a stop. */ up->v[0] = 0.0f; up->v[1] = 0.0f; up->v[2] = 0.0f; (*m)++; } } else v_mad(up->v, v, g, tt); } else v_mad(up->v, v, g, tt); /* Test for collision. */ for (c = 16; c > 0 && tt > 0; c--) { float st; int mi, ms; /* HACK: avoid stepping across path changes. */ st = tt; for (mi = 0; mi < vary->mc; mi++) { struct v_move *mp = vary->mv + mi; struct v_path *pp = vary->pv + mp->pi; if (!pp->f) continue; if (mp->tm + ms_peek(st) > pp->base->tm) st = MS_TO_TIME(pp->base->tm - mp->tm); } /* Miss collisions if we reach the iteration limit. */ if (c > 1) nt = sol_test_file(st, P, V, up, vary); else nt = tt; cmd.type = CMD_STEP_SIMULATION; cmd.stepsim.dt = nt; sol_cmd_enq(&cmd); ms = ms_step(nt); sol_move_step(vary, nt, ms); sol_swch_step(vary, nt, ms); sol_ball_step(vary, nt); if (nt < st) if (b < (d = sol_bounce(up, P, V, nt))) b = d; tt -= nt; } v_sub(a, up->v, a); sol_pendulum(up, a, g, dt); } return b; } /*---------------------------------------------------------------------------*/ void sol_init_sim(struct s_vary *vary) { ms_init(); } void sol_quit_sim(void) { return; } /*---------------------------------------------------------------------------*/
drodin/neverball-old
share/solid_sim_sol.c
C
gpl-2.0
19,801
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2494, 2728, 12849, 10448, 2863, 1008, 1008, 2196, 7384, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>URI.js - URI-Template</title> <meta name="description" content="URI.js is a Javascript library for working with URLs." /> <script src="jquery-3.6.0.min.js" type="text/javascript"></script> <script src="prettify/prettify.js" type="text/javascript"></script> <script src="screen.js" type="text/javascript"></script> <link href="screen.css" rel="stylesheet" type="text/css" /> <link href="prettify/prettify.sunburst.css" rel="stylesheet" type="text/css" /> <script src="src/URI.min.js" type="text/javascript"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-8922143-3']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <style type="text/css"> .tpl-operator { font-weight: bold; color: #669933; } .tpl-variable { font-weight: bold; color: #336699; } .tpl-modifier { font-weight: bold; color: #663399; } pre { padding: 10px; background: #EEE; } table { width: 100%; border: 1px solid #AAA; border-collapse: collapse; } td, th { border: 1px solid #AAA; text-align: left; padding: 3px; } th { background: #EEE; } </style> </head> <body> <a id="github-forkme" href="https://github.com/medialize/URI.js"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a> <div id="container"> <h1><a href="https://github.com/medialize/URI.js">URI.js</a></h1> <ul class="menu"> <li><a href="/URI.js/">Intro</a></li> <li><a href="about-uris.html">Understanding URIs</a></li> <li><a href="docs.html">API-Documentation</a></li> <li><a href="jquery-uri-plugin.html">jQuery Plugin</a></li> <li class="active"><a href="uri-template.html">URI Template</a></li> <li><a href="build.html">Build</a></li> <li><a href="http://rodneyrehm.de/en/">Author</a></li> </ul> <h2>URI Template</h2> <p>As of version 1.7.0 URI.js includes an implementation of URI Templates, as specified in <a href="http://tools.ietf.org/html/rfc6570">RFC 6570</a> (Level 4, March 2012).</p> <h2>Using URI Templates</h2> <pre class="prettyprint lang-js"> // creating a new URI Template var template = new URITemplate("http://example.org/{file}"); var result = template.expand({file: "hello world.html"}); result === "http://example.org/hello%20world.html"; // of course you can call the constructor like a function and chain things: result = URITemplate("http://example.org/{file}") .expand({file: "hello world.html"}); result === "http://example.org/hello%20world.html"; // access via URI result = URI.expand("http://example.org/{file}", {file: "hello world.html"}); // result == new URI("http://example.org/hello%20world.html"); // expand() accepts data-callbacks: template.expand(function(key) { var data = {file: "hello world.html"}; return data[key]; }); // expand() accepts key-callbacks: template.expand({file : function(key) { return "hello world.html"; }}); // Using strict mode var template = new URITemplate("http://example.org/{file}"); var result = template.expand({filename: "hello world.html"}, { strict: true }); // Uncaught Error: Missing expansion value for variable "file" </pre> <h2>URI Template Syntax</h2> <p><em>Expressions</em> are placeholders which are to be substituted by the values their variables reference.</p> <ul> <li><code>http://example.org/~<strong>{<em class="tpl-variable">username</em>}</strong>/</code></li> <li><code>http://example.org/dictionary/<strong>{<em class="tpl-variable">term</em><span class="tpl-modifier">:1</span>}</strong>/<strong>{<em class="tpl-variable">term</em>}</strong></code></li> <li><code>http://example.org/search<strong>{<span class="tpl-operator">?</span><em class="tpl-variable">q</em><span class="tpl-modifier">*</span>,<em class="tpl-variable">lang</em>}</strong></code></li> </ul> <p> An expression consists of an <span class="tpl-operator">operator</span> and a (comma-separated) list of <em>variable-specifications</em>. A variable-specification consists of a <em class="tpl-variable">variable</em> and an optional <em class="tpl-modifier">modifier</em>. </p> <hr> <p>Given the template</p> <pre><code>http://example.org/~<strong>{<em class="tpl-variable">username</em>}</strong>/<strong>{<em class="tpl-variable">term</em><span class="tpl-modifier">:1</span>}</strong>/<strong>{<em class="tpl-variable">term</em>}</strong><strong>{<span class="tpl-operator">?</span><em class="tpl-variable">q</em><span class="tpl-modifier">*</span>,<em class="tpl-variable">lang</em>}</strong></code></pre> <p>and the following data: </p> <pre><code>{username: "rodneyrehm", term: "hello world", q: {a: "mars", b: "jupiter"}, lang: "en"}</code></pre> <p>the expansion looks as follows: <pre><code>"http://example.org/~rodneyrehm/h/hello%20world?a=mars&amp;b=jupiter&amp;lang=en"</code></pre> <hr> <p>List of supported <span class="tpl-operator">operators</span>:</p> <table> <tr><th>Operator</th><th>Description</th></tr> <tr><td><code><em>None</em></code></td><td>Simple String Expansion;</td></tr> <tr><td><code>+</code></td><td>Reserved character strings;</td></tr> <tr><td><code>#</code></td><td>Fragment identifiers prefixed by "#";</td></tr> <tr><td><code>.</code></td><td>Name labels or extensions prefixed by ".";</td></tr> <tr><td><code>/</code></td><td>Path segments prefixed by "/";</td></tr> <tr><td><code>;</code></td><td>Path parameter name or name=value pairs prefixed by ";";</td></tr> <tr><td><code>?</code></td><td>Query component beginning with "?" and consisting of name=value pairs separated by "&amp;"; and,</td></tr> <tr><td><code>&amp;</code></td><td>Continuation of query-style &amp;name=value pairs within a literal query component.</td></tr> </table> <p>List of supported <span class="tpl-modifier">modifiers</span>:</p> <table> <tr><th>Modifier</th><th>Description</th></tr> <tr><td><code><em>None</em></code></td><td>No modification, arrays and objects are joined with ","</td></tr> <tr><td><code>*</code></td><td>Explode arrays and objects (see tables below)</td></tr> <tr><td><code>:3</code></td><td>Substring of the first 3 characters of the variable's value</td></tr> </table> <h3>Strings and Numbers</h3> <p> Given <code>{"var": "hello[world]"}</code>, the expression <code>{var}</code> expands to <code>hello%5Bworld%5D</code>. The following table shows an output matrix for every possible operator/modifier combination produced for <code>string</code> input. </p> <table> <tr><th></th><th colspan="3">Modifier</th></tr> <tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr> <tr><td><code><em>None</em></code></td><td><code>hello%5Bworld%5D</code></td><td><code>hello%5Bworld%5D</code></td><td><code>he</code></td></tr> <tr><td><code><em>+</em></code></td><td><code>hello[world]</code></td><td><code>hello[world]</code></td><td><code>he</code></td></tr> <tr><td><code>#</code></td><td><code>#hello[world]</code></td><td><code>#hello[world]</code></td><td><code>#he</code></td></tr> <tr><td><code>.</code></td><td><code>.hello%5Bworld%5D</code></td><td><code>.hello%5Bworld%5D</code></td><td><code>.he</code></td></tr> <tr><td><code>/</code></td><td><code>/hello%5Bworld%5D</code></td><td><code>/hello%5Bworld%5D</code></td><td><code>/he</code></td></tr> <tr><td><code>;</code></td><td><code>;var=hello%5Bworld%5D</code></td><td><code>;var=hello%5Bworld%5D</code></td><td><code>;var=he</code></td></tr> <tr><td><code>?</code></td><td><code>?var=hello%5Bworld%5D</code></td><td><code>?var=hello%5Bworld%5D</code></td><td><code>?var=he</code></td></tr> <tr><td><code>&amp;</code></td><td><code>&amp;var=hello%5Bworld%5D</code></td><td><code>&amp;var=hello%5Bworld%5D</code></td><td><code>&amp;var=he</code></td></tr> </table> <h3>Arrays</h3> <p> Given <code>{"var": ["one", "two", "three"]}</code>, the expression <code>{var}</code> expands to <code>one,two,three</code>. The following table shows an output matrix for every possible operator/modifier combination produced for <code>array</code> input. </p> <table> <tr><th></th><th colspan="3">Modifier</th></tr> <tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr> <tr><td><code><em>None</em></code></td><td><code>one,two,three</code></td><td><code>one,two,three</code></td><td><code>on,tw,th</code></td></tr> <tr><td><code><em>+</em></code></td><td><code>one,two,three</code></td><td><code>one,two,three</code></td><td><code>on,tw,th</code></td></tr> <tr><td><code>#</code></td><td><code>#one,two,three</code></td><td><code>#one,two,three</code></td><td><code>#on,tw,th</code></td></tr> <tr><td><code>.</code></td><td><code>.one,two,three</code></td><td><code>.one.two.three</code></td><td><code>.on,tw,th</code></td></tr> <tr><td><code>/</code></td><td><code>/one,two,three</code></td><td><code>/one/two/three</code></td><td><code>/on,tw,th</code></td></tr> <tr><td><code>;</code></td><td><code>;var=one,two,three</code></td><td><code>;var=one;var=two;var=three</code></td><td><code>;var=on,tw,th</code></td></tr> <tr><td><code>?</code></td><td><code>?var=one,two,three</code></td><td><code>?var=one&amp;var=two&amp;var=three</code></td><td><code>?var=on,tw,th</code></td></tr> <tr><td><code>&amp;</code></td><td><code>&amp;var=one,two,three</code></td><td><code>&amp;var=one&amp;var=two&amp;var=three</code></td><td><code>&amp;var=on,tw,th</code></td></tr> </table> <h3>Objects ("plain objects" / "hash maps")</h3> <p> Given <code>{"var": {"one": "alpha", "two": "bravo"}}</code>, the expression <code>{var}</code> expands to <code>one,two,three</code>. The following table shows an output matrix for every possible operator/modifier combination produced for <code>object</code> input. </p> <table> <tr><th></th><th colspan="3">Modifier</th></tr> <tr><th>Operator</th><th><em>None</em></th><th>*</th><th>:2</th></tr> <tr><td><code><em>None</em></code></td><td><code>one,alpha,two,bravo</code></td><td><code>one=alpha,two=bravo</code></td><td><code>on,al,tw,br</code></td></tr> <tr><td><code><em>+</em></code></td><td><code>one,alpha,two,bravo</code></td><td><code>one=alpha,two=bravo</code></td><td><code>on,al,tw,br</code></td></tr> <tr><td><code>#</code></td><td><code>#one,alpha,two,bravo</code></td><td><code>#one=alpha,two=bravo</code></td><td><code>#on,al,tw,br</code></td></tr> <tr><td><code>.</code></td><td><code>.one,alpha,two,bravo</code></td><td><code>.one=alpha.two=bravo</code></td><td><code>.on,al,tw,br</code></td></tr> <tr><td><code>/</code></td><td><code>/one,alpha,two,bravo</code></td><td><code>/one=alpha/two=bravo</code></td><td><code>/on,al,tw,br</code></td></tr> <tr><td><code>;</code></td><td><code>;var=one,alpha,two,bravo</code></td><td><code>;one=alpha;two=bravo</code></td><td><code>;var=on,al,tw,br</code></td></tr> <tr><td><code>?</code></td><td><code>?var=one,alpha,two,bravo</code></td><td><code>?one=alpha&amp;two=bravo</code></td><td><code>?var=on,al,tw,br</code></td></tr> <tr><td><code>&amp;</code></td><td><code>&amp;var=one,alpha,two,bravo</code></td><td><code>&amp;one=alpha&amp;two=bravo</code></td><td><code>&amp;var=on,al,tw,br</code></td></tr> </table> <h2>Limitations</h2> <p>URI Template is a <em>Proposed Standard</em> and because of that I did not want to deviate from it. That said I'm not at all happy with how the specification turned out. Here are some of my thoughts:</p> <ul> <li>The <em>explode modifier</em> works the wrong way. <code>{?some_object}</code> should lead to <code>?foo=bar&amp;hello=world</code>, as this is the common expansion</li> <li>The <em>prefix modifier</em> (which I would've named <em>truncate modifier</em>) only has an end-offset. The specification says it's »used to partition an identifier space hierarchically«. <code>abc</code> may become <code>a/bc</code> or <code>a/ab/abc</code>. But there is no way of modifying output to <code>a/b/c</code> or <code>a/b/abc</code>. Whenever I had to partition identifier spaces, I used one of the latter patterns.</li> <li>Operators like <code>.</code> automatically prefix the expansion. So <code>{"var": ["filename", "extension"]}</code> and <code>{.var*}</code> results in <code>.filename.extension</code> - obviously not what I wanted.</li> <li>Variable names (<em>varname</em>) may only contain <code>ALPHA / DIGIT / "_" / pct-encoded</code> and may not be decoded for resolving the reference. This simply feels weird, especially the "may not be decoded" part.</li> <li>Other possible modifiers could include some simple character-munging like <em>UPPERCASE</em>, <em>LOWERCASE</em>, <em>CAPITALCASE</em></li> <li><code>{/var,empty,empty}</code> results in <code>/foobar//</code> - clearly not what one intended</li> <li><code>{var}</code> and <code>{"var" : {"a": "1", "b": "2"}}</code> results in <code>a,1,b,2</code> - excusemewhat? I would've expected <code>a=1,b=2</code> or <code>a:1,b:2</code> (in a perverse parallel universe).</li> <li>Spaces in the <em>query string</em> should be encoded to <code>+</code>, not <code>%20</code> according to <a href="http://www.w3.org/TR/html401/interact/forms.html#form-content-type">application/x-www-form-urlencoded</a></li> </ul> </div> </body> </html>
medialize/URI.js
uri-template.html
HTML
mit
14,623
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
""" Consider this game: Write 8 blanks on a sheet of paper. Randomly pick a digit 0-9. After seeing the digit, choose one of the 8 blanks to place that digit in. Randomly choose another digit (with replacement) and then choose one of the 7 remaining blanks to place it in. Repeat until you've filled all 8 blanks. You win if the 8 digits written down are in order from smallest to largest. Write a program that plays this game by itself and determines whether it won or not. Run it 1 million times and post your probability of winning. Assigning digits to blanks randomly lets you win about 0.02% of the time. Here's a python script that wins about 10.3% of the time. Can you do better? import random def trial(): indices = range(8) # remaining unassigned indices s = [None] * 8 # the digits in their assigned places while indices: d = random.randint(0,9) # choose a random digit index = indices[int(d*len(indices)/10)] # assign it an index s[index] = str(d) indices.remove(index) return s == sorted(s) print sum(trial() for _ in range(1000000)) thanks to cosmologicon for the challenge at /r/dailyprogrammer_ideas .. link [http://www.reddit.com/r/dailyprogrammer_ideas/comments/s30be/intermediate_digitassigning_game/] """ import random import itertools def que_sort(data): # print(data) return all(b >= a for a, b in zip(data, itertools.islice(data, 1, None))) TRIALS = 1 win = 0 for a in range(TRIALS): l = [None] * 8 p = list(range(8)) while p: d = random.randint(0,9) # i = random.choice(p) i = int(d * (len(p)) / 10) print(p[i]) l[p[i]] = d p.pop(i) print(l) if que_sort(l): win += 1 print('{}/{} - {}%'.format(win, TRIALS, win/TRIALS*100))
DayGitH/Python-Challenges
DailyProgrammer/20120430B.py
Python
mit
1,804
[ 30522, 1000, 1000, 1000, 5136, 2023, 2208, 1024, 4339, 1022, 8744, 2015, 2006, 1037, 7123, 1997, 3259, 1012, 18154, 4060, 1037, 15340, 1014, 1011, 1023, 1012, 2044, 3773, 1996, 15340, 1010, 5454, 2028, 1997, 1996, 1022, 8744, 2015, 2000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module Keisan module Functions class ExpressionFunction < Function attr_reader :arguments, :expression def initialize(name, arguments, expression, transient_definitions) super(name, arguments.count) if expression.is_a?(::String) @expression = AST::parse(expression) else @expression = expression.deep_dup end @arguments = arguments @transient_definitions = transient_definitions end def freeze @arguments.freeze @expression.freeze super end def call(context, *args) validate_arguments!(args.count) local = local_context_for(context) arguments.each.with_index do |arg_name, i| local.register_variable!(arg_name, args[i]) end expression.value(local) end def value(ast_function, context = nil) validate_arguments!(ast_function.children.count) context ||= Context.new argument_values = ast_function.children.map {|child| child.value(context)} call(context, *argument_values) end def evaluate(ast_function, context = nil) validate_arguments!(ast_function.children.count) context ||= Context.new local = local_context_for(context) argument_values = ast_function.children.map {|child| child.evaluate(context)} arguments.each.with_index do |arg_name, i| local.register_variable!(arg_name, argument_values[i].evaluate(context)) end expression.evaluated(local) end def simplify(ast_function, context = nil) validate_arguments!(ast_function.children.count) ast_function.instance_variable_set( :@children, ast_function.children.map {|child| child.evaluate(context)} ) if ast_function.children.all? {|child| child.is_a?(AST::ConstantLiteral)} value(ast_function, context).to_node.simplify(context) else ast_function end end # Multi-argument functions work as follows: # Given f(x, y), in general we will take the derivative with respect to t, # and x = x(t), y = y(t). For instance d/dt f(2*t, t+1). # In this case, chain rule gives derivative: # dx(t)/dt * f_x(x(t), y(t)) + dy(t)/dt * f_y(x(t), y(t)), # where f_x and f_y are the x and y partial derivatives respectively. def differentiate(ast_function, variable, context = nil) validate_arguments!(ast_function.children.count) local = local_context_for(context) argument_values = ast_function.children.map {|child| child.evaluated(local)} argument_derivatives = ast_function.children.map do |child| child.differentiated(variable, context) end partial_derivatives = calculate_partial_derivatives(context) AST::Plus.new( argument_derivatives.map.with_index {|argument_derivative, i| partial_derivative = partial_derivatives[i] argument_variables.each.with_index {|argument_variable, j| partial_derivative = partial_derivative.replaced(argument_variable, argument_values[j]) } AST::Times.new([argument_derivative, partial_derivative]) } ) end private def argument_variables arguments.map {|argument| AST::Variable.new(argument)} end def calculate_partial_derivatives(context) argument_variables.map.with_index do |variable, i| partial_derivative = expression.differentiated(variable, context) end end def local_context_for(context = nil) context ||= Context.new context.spawn_child(definitions: @transient_definitions, shadowed: @arguments, transient: true) end end end end
project-eutopia/keisan
lib/keisan/functions/expression_function.rb
Ruby
mit
3,851
[ 30522, 11336, 26679, 8791, 11336, 4972, 2465, 3670, 11263, 27989, 1026, 3853, 2012, 16344, 1035, 8068, 1024, 9918, 1010, 1024, 3670, 13366, 3988, 4697, 1006, 2171, 1010, 9918, 1010, 3670, 1010, 25354, 1035, 15182, 1007, 3565, 1006, 2171, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright 1996-2008 Ariba, Inc. 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. $Id: //ariba/platform/util/core/ariba/util/core/LockHandlerConditions.java#4 $ */ package ariba.util.core; /** @aribaapi private */ public interface LockHandlerConditions { /** return false to indicate continuation context is allocated by caller to LockHandler.doWithLock and can be used to pass, by reference, any number of result data etc. Called WITH LOCK */ public boolean doWithLock (LockHandlerContext lockHandlerContext); /** the time, in milliseconds, to wait Called WITH LOCK */ public long timeoutIntervalMillis (); }
pascalrobert/aribaweb
src/util/src/main/java/ariba/util/core/LockHandlerConditions.java
Java
apache-2.0
1,211
[ 30522, 1013, 1008, 9385, 2727, 30524, 8299, 1024, 1013, 1013, 7479, 1012, 15895, 1012, 8917, 1013, 15943, 1013, 6105, 1011, 1016, 1012, 1014, 4983, 3223, 2011, 12711, 2375, 2030, 3530, 2000, 1999, 3015, 1010, 4007, 5500, 2104, 1996, 6105, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#! /bin/sh # # build.sh # Copyright (C) 2014 hzsunshx <hzsunshx@onlinegame-13-180> # # Distributed under terms of the MIT license. # GOOS=android GOARCH=arm CGO_ENABLED=1 go build -o air-native cp air-native dist/
NetEase/airinput
build.sh
Shell
mit
215
[ 30522, 1001, 999, 1013, 8026, 1013, 14021, 1001, 1001, 3857, 1012, 14021, 1001, 9385, 1006, 1039, 1007, 2297, 22100, 19729, 4095, 2595, 1026, 22100, 19729, 4095, 2595, 1030, 3784, 16650, 1011, 2410, 1011, 8380, 1028, 1001, 1001, 5500, 2104,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * World Calendars * https://github.com/alexcjohnson/world-calendars * * Batch-converted from kbwood/calendars * Many thanks to Keith Wood and all of the contributors to the original project! * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /* http://keith-wood.name/calendars.html Hindi INDIA localisation for Gregorian/Julian calendars for jQuery. Written by Pawan Kumar Singh. */ var main = require('../main'); var _gregorian = main.calendars.gregorian; var _julian = main.calendars.julian; _gregorian.prototype.regionalOptions['hi-IN'] = { name: 'Gregorian', epochs: ['BCE', 'CE'], monthNames: ['जनवरी',' फरवरी', 'मार्च', 'अप्रैल', 'मई', 'जून','जुलाई', 'अगस्त', 'सितम्बर', 'अक्टूबर', 'नवम्बर', 'दिसम्बर'], monthNamesShort: ['जन', 'फर', 'मार्च','अप्रै', 'मई', 'जून','जुलाई', 'अग', 'सित', 'अक्टू', 'नव', 'दिस'], dayNames: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार'], dayNamesShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'], dayNamesMin: ['र','सो','मं','बु','गु','शु','श'], digits: null, dateFormat: 'dd/mm/yyyy', firstDay: 1, isRTL: false }; if (_julian) { _julian.prototype.regionalOptions['hi-IN'] = _gregorian.prototype.regionalOptions['hi-IN']; }
useabode/redash
node_modules/world-calendars/dist/regional/hi-IN.js
JavaScript
bsd-2-clause
1,725
[ 30522, 1013, 1008, 1008, 2088, 8094, 2015, 1008, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 4074, 2278, 5558, 7295, 3385, 1013, 2088, 1011, 8094, 2015, 1008, 1008, 14108, 1011, 4991, 2013, 21677, 3702, 1013, 8094, 2015, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.13"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>CQRS.NET: Member List</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); </script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectlogo"><img alt="Logo" src="ChinChilla-Software-Red.png"/></td> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">CQRS.NET &#160;<span id="projectnumber">2.0</span> </div> <div id="projectbrief">A lightweight enterprise framework to write CQRS, event-sourced and micro-service applications in hybrid multi-datacentre, on-premise and Azure environments.</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.13 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); </script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html','');}); </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="headertitle"> <div class="title">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken Member List</div> </div> </div><!--header--> <div class="contents"> <p>This is the complete list of members for <a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken</a>, including all inherited members.</p> <table class="directory"> <tr class="even"><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken_a1443fa350c304438a9a57c458717eeef.html#a1443fa350c304438a9a57c458717eeef">DateIssued</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken</a></td><td class="entry"></td></tr> <tr><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity_a70118763769fc358c7206ef04f12ff6f.html#a70118763769fc358c7206ef04f12ff6f">id</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity.html">Cqrs.Azure.DocumentDb.Entities.AzureDocumentDbEntity</a></td><td class="entry"></td></tr> <tr class="even"><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity_ad3a216109e53eaa53aa1aa18eaea1f3a.html#ad3a216109e53eaa53aa1aa18eaea1f3a">IsLogicallyDeleted</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity.html">Cqrs.Azure.DocumentDb.Entities.AzureDocumentDbEntity</a></td><td class="entry"></td></tr> <tr><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity_a9f8073973963c42fc44bb5fba84cf70a.html#a9f8073973963c42fc44bb5fba84cf70a">Rsn</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity.html">Cqrs.Azure.DocumentDb.Entities.AzureDocumentDbEntity</a></td><td class="entry"></td></tr> <tr class="even"><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken_a55c07b93600e6863985b50d4df346af0.html#a55c07b93600e6863985b50d4df346af0">Serialise</a>()</td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken</a></td><td class="entry"></td></tr> <tr><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity_a65addaa44fbb57497e730f4f806bc820.html#a65addaa44fbb57497e730f4f806bc820">SortingOrder</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity.html">Cqrs.Azure.DocumentDb.Entities.AzureDocumentDbEntity</a></td><td class="entry"></td></tr> <tr class="even"><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken_a72467ad344da70ee03355d03f9a3f25e.html#a72467ad344da70ee03355d03f9a3f25e">TimeOfExpiry</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken</a></td><td class="entry"></td></tr> <tr><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken_ad8db4fad59b85056e4e37c9e29226425.html#ad8db4fad59b85056e4e37c9e29226425">Token</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken.html">Cqrs.Azure.DocumentDb.Repositories.Authentication.AzureSingleSignOnToken</a></td><td class="entry"></td></tr> <tr class="even"><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity_a4696c1d70da779b260ba76588aff80a7.html#a4696c1d70da779b260ba76588aff80a7">type</a></td><td class="entry"><a class="el" href="classCqrs_1_1Azure_1_1DocumentDb_1_1Entities_1_1AzureDocumentDbEntity.html">Cqrs.Azure.DocumentDb.Entities.AzureDocumentDbEntity</a></td><td class="entry"></td></tr> </table></div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> </ul> </div> </body> </html>
Chinchilla-Software-Com/CQRS
wiki/docs/2.0/html/classCqrs_1_1Azure_1_1DocumentDb_1_1Repositories_1_1Authentication_1_1AzureSingleSignOnToken-members.html
HTML
lgpl-2.1
8,439
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * */ package ee.ioc.cs.jbe.browser.codeedit; import java.util.ArrayList; import org.apache.bcel.generic.*; import org.gjt.jclasslib.bytecode.OpcodesUtil; public class JAsmParser { /* * Parses the input code and returns an instructionlist, but also has a * sideeffect: it updates the constant pool on the fly to have the required * constants in the constant pool. */ private JAsmParseException parseException = new JAsmParseException(); public InstructionList parse(String code, ConstantPoolGen cpg) throws JAsmParseException { code = code.replaceAll("\r", ""); String[] codeLines = code.split("\n"); if (codeLines.length == 1 && codeLines[0].equals("")) { return new InstructionList(); } InstructionList instructions = new InstructionList(); ArrayList<InstructionHandle> instructionHandleList = new ArrayList<InstructionHandle> (); ArrayList<TempSwitchData> lookupSwitches = new ArrayList<TempSwitchData>(); ArrayList<TempSwitchData> tableSwitches = new ArrayList<TempSwitchData>(); ArrayList<BranchPair> branches = new ArrayList<BranchPair>(); InstructionHandle ih; String[] instrElems; int codeLength = countLines(codeLines); // InstructionHandle[] iha = new InstructionHandle[strt.countTokens()]; int labels = 0; int switchMode = 0; // 0- normal , 1- tableswitch, 2 - lookupswitch String fullInstr; String instrName; TempSwitchData tempSwitch = new TempSwitchData(); for (int i = 0; i < codeLines.length; i++) { fullInstr = codeLines[i]; //switchmode, 1 denoting tableswitch, 2 lookupswitch if (beginsWithWhitespace(fullInstr) && switchMode == 1) { boolean isDefault = isDefaultLine(fullInstr.trim()); if (isDefault) { int target = getLookupTarget(fullInstr.trim(), labels, codeLength); tempSwitch.getBranchPairs().add( new BranchPair(-1, target)); } else { int target = getTableArg(fullInstr.trim(), labels, codeLength); tempSwitch.getBranchPairs().add( new BranchPair(tempSwitch.getInitialLab(), target)); tempSwitch.incInitialLab(); } } else if (beginsWithWhitespace(fullInstr) && switchMode == 2) { int target = getLookupTarget(fullInstr.trim(), labels, codeLength); int value = getLookupSource(fullInstr.trim(), labels); tempSwitch.getBranchPairs().add(new BranchPair(value, target)); } else if (beginsWithWhitespace(fullInstr)) { parseException.addError(JAsmParseException.WHITESPACE_ERROR, fullInstr, labels-1); } else { if (switchMode == 1) { TABLESWITCH ts = new TABLESWITCH(); ih = instructions.append(ts); instructionHandleList.add(ih); tempSwitch.setHandle(ih); tableSwitches.add(tempSwitch); labels++; switchMode = 0; } else if (switchMode == 2) { LOOKUPSWITCH ls = new LOOKUPSWITCH(); ih = instructions.append(ls); instructionHandleList.add(ih); tempSwitch.setHandle(ih); lookupSwitches.add(tempSwitch); labels++; switchMode = 0; } instrElems = fullInstr.split(" "); instrName = instrElems[0].toLowerCase().trim(); if (instrName.equals("bipush")) { byte arg = getSingleByteArg(instrElems, labels); ih = instructions.append(new BIPUSH(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("sipush")) { short arg = getSingleShortArg(instrElems, labels); ih = instructions.append(new SIPUSH(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iinc")) { int arg1 = 0; int arg2 = 0; try { arg1 = Integer.parseInt(instrElems[1]); arg2 = Integer.parseInt(instrElems[2]); } catch (NumberFormatException nfe) { parseException.addError( JAsmParseException.INT_REQUIRED, instrElems[0], labels); } catch (ArrayIndexOutOfBoundsException aobe) { parseException.addError( JAsmParseException.MISSING_ARGUMENTS, instrElems[0], labels); } ih = instructions.append(new IINC(arg1, arg2)); instructionHandleList.add(ih); labels++; } /* * Class and object operations. */ else if (instrName.equals("anewarray")) { int arg = getClassConstRef(instrElems, cpg, labels); ih = instructions.append(new ANEWARRAY(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("checkcast")) { int arg = getClassConstRef(instrElems, cpg, labels); ih = instructions.append(new CHECKCAST(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("instanceof")) { int arg = getClassConstRef(instrElems, cpg, labels); ih = instructions.append(new INSTANCEOF(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("new")) { int arg = getClassConstRef(instrElems, cpg, labels); ih = instructions.append(new NEW(arg)); instructionHandleList.add(ih); labels++; } /* * Invoke instructions */ else if (instrName.equals("invokevirtual")) { int arg = getMethodConstRef(instrElems, cpg, labels); ih = instructions.append(new INVOKEVIRTUAL(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("invokestatic")) { int arg = getMethodConstRef(instrElems, cpg, labels); ih = instructions.append(new INVOKESTATIC(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("invokespecial")) { int arg = getMethodConstRef(instrElems, cpg, labels); ih = instructions.append(new INVOKESPECIAL(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("invokeinterface")) { int index = getInterfaceConstRef(instrElems, cpg, labels); int nargs = Integer.parseInt(instrElems[2]); ih = instructions.append(new INVOKEINTERFACE(index, nargs)); instructionHandleList.add(ih); labels++; } /* * Field instructions */ else if (instrName.equals("getstatic")) { int arg = getFieldConstRef(instrElems, cpg, labels); ih = instructions.append(new GETSTATIC(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("getfield")) { int arg = getFieldConstRef(instrElems, cpg, labels); ih = instructions.append(new GETFIELD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("putstatic")) { int arg = getFieldConstRef(instrElems, cpg, labels); ih = instructions.append(new PUTSTATIC(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("putfield")) { int arg = getFieldConstRef(instrElems, cpg, labels); ih = instructions.append(new PUTFIELD(arg)); instructionHandleList.add(ih); labels++; } /* * Newarray instructions */ else if (instrName.equals("newarray")) { byte arg = getArrayRef(instrElems, labels); ih = instructions.append(new NEWARRAY(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("multianewarray")) { short dim = 1; int arg = 0; try { dim = Short.parseShort(instrElems[2]); } catch (NumberFormatException nfe) { parseException.addError( JAsmParseException.SHORT_REQUIRED, instrElems[0], labels); } catch (ArrayIndexOutOfBoundsException aobe) { parseException.addError( JAsmParseException.MISSING_ARGUMENTS, instrElems[0], labels); } try { arg = Integer.parseInt(instrElems[1]); } catch (NumberFormatException nfe) { String classN = instrElems[1]; arg = cpg.addClass(classN); } catch (ArrayIndexOutOfBoundsException aobe) { parseException.addError( JAsmParseException.MISSING_ARGUMENTS, instrElems[0], labels); } ih = instructions.append(new MULTIANEWARRAY(arg, dim)); instructionHandleList.add(ih); labels++; } /* * Load constant instructions */ else if (instrName.equals("ldc")) { int arg = getConstRef4ldc(instrElems, cpg, labels); ih = instructions.append(new LDC(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ldc_w")) { int arg = getConstRef4ldc(instrElems, cpg, labels); ih = instructions.append(new LDC_W(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ldc2_w")) { int arg = getConstRefldc2_w(instrElems, cpg, labels); ih = instructions.append(new LDC2_W(arg)); instructionHandleList.add(ih); labels++; } /* * Local Variable instructions */ else if (instrName.equals("ret")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new RET(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aload")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new ALOAD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("astore")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new ASTORE(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dload")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new DLOAD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dstore")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new DSTORE(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fload")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new FLOAD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fstore")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new FSTORE(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iload")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new ILOAD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("istore")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new ISTORE(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lload")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new LLOAD(arg)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lstore")) { int arg = getSingleIntArg(instrElems, labels); ih = instructions.append(new LSTORE(arg)); instructionHandleList.add(ih); labels++; } /* * Switch instructions */ else if (instrName.equals("tableswitch")) { switchMode = 1; int arg = getSingleIntArg(instrElems, labels); tempSwitch = new TempSwitchData(2, arg); } else if (instrName.equals("lookupswitch")) { switchMode = 2; tempSwitch = new TempSwitchData(1); } /* * 0 parameter instructions */ else if (instrName.equals("aaload")) { ih = instructions.append(new AALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aastore")) { ih = instructions.append(new AASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aconst_null")) { ih = instructions.append(new ACONST_NULL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aload_0")) { ih = instructions.append(new ALOAD(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aload_1")) { ih = instructions.append(new ALOAD(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aload_2")) { ih = instructions.append(new ALOAD(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("aload_3")) { ih = instructions.append(new ALOAD(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("areturn")) { ih = instructions.append(new ARETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("arraylength")) { ih = instructions.append(new ARRAYLENGTH()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("astore_0")) { ih = instructions.append(new ASTORE(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("astore_1")) { ih = instructions.append(new ASTORE(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("astore_2")) { ih = instructions.append(new ASTORE(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("astore_3")) { ih = instructions.append(new ASTORE(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("athrow")) { ih = instructions.append(new ATHROW()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("baload")) { ih = instructions.append(new BALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("bastore")) { ih = instructions.append(new BASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("breakpoint")) { ih = instructions.append(new BREAKPOINT()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("caload")) { ih = instructions.append(new CALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("castore")) { ih = instructions.append(new CASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("d2f")) { ih = instructions.append(new D2F()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("d2i")) { ih = instructions.append(new D2I()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("d2l")) { ih = instructions.append(new D2L()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dadd")) { ih = instructions.append(new DADD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("daload")) { ih = instructions.append(new DALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dastore")) { ih = instructions.append(new DASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dcmpg")) { ih = instructions.append(new DCMPG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dcmpl")) { ih = instructions.append(new DCMPL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dconst_0")) { ih = instructions.append(new DCONST(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dconst_1")) { ih = instructions.append(new DCONST(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ddiv")) { ih = instructions.append(new DDIV()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dload_0")) { ih = instructions.append(new DLOAD(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dload_1")) { ih = instructions.append(new DLOAD(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dload_2")) { ih = instructions.append(new DLOAD(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dload_3")) { ih = instructions.append(new DLOAD(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dmul")) { ih = instructions.append(new DMUL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dneg")) { ih = instructions.append(new DNEG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("drem")) { ih = instructions.append(new DREM()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dreturn")) { ih = instructions.append(new DRETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dstore_0")) { ih = instructions.append(new DSTORE(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dstore_1")) { ih = instructions.append(new DSTORE(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dstore_2")) { ih = instructions.append(new DSTORE(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dstore_3")) { ih = instructions.append(new DSTORE(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dsub")) { ih = instructions.append(new DSUB()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup")) { ih = instructions.append(new DUP()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup2")) { ih = instructions.append(new DUP2()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup2_x1")) { ih = instructions.append(new DUP2_X1()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup2_x2")) { ih = instructions.append(new DUP2_X2()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup_x1")) { ih = instructions.append(new DUP_X1()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("dup_x2")) { ih = instructions.append(new DUP_X2()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("f2d")) { ih = instructions.append(new F2D()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("f2i")) { ih = instructions.append(new F2I()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("f2l")) { ih = instructions.append(new F2L()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fadd")) { ih = instructions.append(new FADD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("faload")) { ih = instructions.append(new FALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fastore")) { ih = instructions.append(new FASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fcmpg")) { ih = instructions.append(new FCMPG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fcmpl")) { ih = instructions.append(new FCMPL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fconst_0")) { ih = instructions.append(new FCONST(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fconst_1")) { ih = instructions.append(new FCONST(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fconst_2")) { ih = instructions.append(new FCONST(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fdiv")) { ih = instructions.append(new FDIV()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fload_0")) { ih = instructions.append(new FLOAD(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fload_1")) { ih = instructions.append(new FLOAD(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fload_2")) { ih = instructions.append(new FLOAD(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fload_3")) { ih = instructions.append(new FLOAD(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fmul")) { ih = instructions.append(new FMUL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fneg")) { ih = instructions.append(new FNEG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("frem")) { ih = instructions.append(new FREM()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("freturn")) { ih = instructions.append(new FRETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fstore_0")) { ih = instructions.append(new FSTORE(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fstore_1")) { ih = instructions.append(new FSTORE(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fstore_2")) { ih = instructions.append(new FSTORE(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fstore_3")) { ih = instructions.append(new FSTORE(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("fsub")) { ih = instructions.append(new FSUB()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2d")) { ih = instructions.append(new I2D()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2f")) { ih = instructions.append(new I2F()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2l")) { ih = instructions.append(new I2L()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iadd")) { ih = instructions.append(new IADD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iaload")) { ih = instructions.append(new IALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iand")) { ih = instructions.append(new IAND()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iastore")) { ih = instructions.append(new IASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_0")) { ih = instructions.append(new ICONST(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_1")) { ih = instructions.append(new ICONST(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_2")) { ih = instructions.append(new ICONST(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_3")) { ih = instructions.append(new ICONST(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_4")) { ih = instructions.append(new ICONST(4)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_5")) { ih = instructions.append(new ICONST(5)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iconst_m1")) { ih = instructions.append(new ICONST(-1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("idiv")) { ih = instructions.append(new IDIV()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iload_0")) { ih = instructions.append(new ILOAD(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iload_1")) { ih = instructions.append(new ILOAD(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iload_2")) { ih = instructions.append(new ILOAD(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iload_3")) { ih = instructions.append(new ILOAD(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("imul")) { ih = instructions.append(new IMUL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ineg")) { ih = instructions.append(new INEG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2b")) { ih = instructions.append(new I2B()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2c")) { ih = instructions.append(new I2C()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("i2s")) { ih = instructions.append(new I2S()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ior")) { ih = instructions.append(new IOR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("irem")) { ih = instructions.append(new IREM()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ireturn")) { ih = instructions.append(new IRETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ishl")) { ih = instructions.append(new ISHL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ishr")) { ih = instructions.append(new ISHR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("istore_0")) { ih = instructions.append(new ISTORE(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("istore_1")) { ih = instructions.append(new ISTORE(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("istore_2")) { ih = instructions.append(new ISTORE(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("istore_3")) { ih = instructions.append(new ISTORE(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("isub")) { ih = instructions.append(new ISUB()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("iushr")) { ih = instructions.append(new IUSHR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ixor")) { ih = instructions.append(new IXOR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("l2d")) { ih = instructions.append(new L2D()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("l2f")) { ih = instructions.append(new L2F()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("l2i")) { ih = instructions.append(new L2I()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ladd")) { ih = instructions.append(new LADD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("laload")) { ih = instructions.append(new LALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("land")) { ih = instructions.append(new LAND()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lastore")) { ih = instructions.append(new LASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lcmp")) { ih = instructions.append(new LCMP()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lconst_0")) { ih = instructions.append(new LCONST(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lconst_1")) { ih = instructions.append(new LCONST(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("ldiv")) { ih = instructions.append(new LDIV()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lload_0")) { ih = instructions.append(new LLOAD(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lload_1")) { ih = instructions.append(new LLOAD(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lload_2")) { ih = instructions.append(new LLOAD(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lload_3")) { ih = instructions.append(new LLOAD(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lmul")) { ih = instructions.append(new LMUL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lneg")) { ih = instructions.append(new LNEG()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lor")) { ih = instructions.append(new LOR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lrem")) { ih = instructions.append(new LREM()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lreturn")) { ih = instructions.append(new LRETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lshl")) { ih = instructions.append(new LSHL()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lshr")) { ih = instructions.append(new LSHR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lstore_0")) { ih = instructions.append(new LSTORE(0)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lstore_1")) { ih = instructions.append(new LSTORE(1)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lstore_2")) { ih = instructions.append(new LSTORE(2)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lstore_3")) { ih = instructions.append(new LSTORE(3)); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lsub")) { ih = instructions.append(new LSUB()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lushr")) { ih = instructions.append(new LUSHR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("lxor")) { ih = instructions.append(new LXOR()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("monitorenter")) { ih = instructions.append(new MONITORENTER()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("monitorexit")) { ih = instructions.append(new MONITOREXIT()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("nop")) { ih = instructions.append(new NOP()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("pop")) { ih = instructions.append(new POP()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("pop2")) { ih = instructions.append(new POP2()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("return")) { ih = instructions.append(new RETURN()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("saload")) { ih = instructions.append(new SALOAD()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("sastore")) { ih = instructions.append(new SASTORE()); instructionHandleList.add(ih); labels++; } else if (instrName.equals("swap")) { ih = instructions.append(new SWAP()); instructionHandleList.add(ih); labels++; } // Jump instructions else if (instrName.equals("goto")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new GOTO(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("goto_w")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new GOTO_W(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_acmpeq")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ACMPEQ(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_acmpne")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ACMPNE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmpeq")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPEQ(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmpge")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPGE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmpgt")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPGT(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmple")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPLE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmplt")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPLT(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("if_icmpne")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IF_ICMPNE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifeq")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFEQ(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifge")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFGE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifgt")) { int arg = getJumpArg(instrElems, labels, codeLength); ; ih = instructions.append(new IFGT(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifle")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFLE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("iflt")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFLT(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifne")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFNE(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifnonnull")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFNONNULL(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("ifnull")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new IFNULL(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("jsr")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new JSR(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else if (instrName.equals("jsr_w")) { int arg = getJumpArg(instrElems, labels, codeLength); ih = instructions.append(new JSR_W(null)); instructionHandleList.add(ih); branches.add(new BranchPair(labels, arg)); labels++; } else { parseException.addError(JAsmParseException.SYNTAX_ERROR, fullInstr, labels); labels++; } } } if (parseException.errorCount() > 0) { throw parseException; } for (int i = 0; i < lookupSwitches.size(); i++) { TempSwitchData tsd = (TempSwitchData) lookupSwitches.get(i); int targetArrSize = 0; for (int j = 0; j < tsd.getBranchPairs().size(); j++) { BranchPair bp = (BranchPair) tsd.getBranchPairs().get(j); if (bp.source != -1) { targetArrSize++; } } int[] targets = new int[targetArrSize]; InstructionHandle[] targetInstrs = new InstructionHandle[targetArrSize]; int count = 0; InstructionHandle defaultTarget = null; for (int j = 0; j < tsd.getBranchPairs().size(); j++) { BranchPair bp = (BranchPair) tsd.getBranchPairs().get(j); if (bp.source != -1) { targets[count] = bp.source; targetInstrs[count] = (InstructionHandle) instructionHandleList .get(bp.target - 1); count++; } else { defaultTarget = (InstructionHandle) instructionHandleList .get(bp.target - 1); } } LOOKUPSWITCH lus = (LOOKUPSWITCH) tsd.ih.getInstruction(); lus.setMatchesTargets(targets, targetInstrs); lus.setTarget(defaultTarget); } for (int i = 0; i < tableSwitches.size(); i++) { TempSwitchData tsd = (TempSwitchData) tableSwitches.get(i); int targetArrSize = 0; for (int j = 0; j < tsd.getBranchPairs().size(); j++) { BranchPair bp = (BranchPair) tsd.getBranchPairs().get(j); if (bp.source != -1) { targetArrSize++; } } int[] targets = new int[targetArrSize]; InstructionHandle[] targetInstrs = new InstructionHandle[targetArrSize]; int count = 0; InstructionHandle defaultTarget = null; for (int j = 0; j < tsd.getBranchPairs().size(); j++) { BranchPair bp = (BranchPair) tsd.getBranchPairs().get(j); if (bp.source != -1) { targets[count] = bp.source; targetInstrs[count] = (InstructionHandle) instructionHandleList .get(bp.target - 1); count++; } else { defaultTarget = (InstructionHandle) instructionHandleList .get(bp.target - 1); } } TABLESWITCH ts = (TABLESWITCH) tsd.ih.getInstruction(); ts.setMatchesTargets(targets, targetInstrs); ts.setTarget(defaultTarget); } for (int i = 0; i < branches.size(); i++) { BranchPair bp = (BranchPair) branches.get(i); ih = (InstructionHandle) instructionHandleList.get(bp.source); if (ih.getInstruction() instanceof GotoInstruction) { GotoInstruction jInst = (GotoInstruction) ih.getInstruction(); jInst.setTarget((InstructionHandle) instructionHandleList .get(bp.target - 1)); } else { IfInstruction jInst = (IfInstruction) ih.getInstruction(); jInst.setTarget((InstructionHandle) instructionHandleList .get(bp.target - 1)); } } return instructions; } private boolean isDefaultLine(String arg) { String[] args = arg.split(":"); if (args.length == 2 & args[0].trim().equals("default")) { return true; } return false; } private int getLookupSource(String arg, int line) { try { String[] args = arg.split(":"); if (args.length != 2) { parseException.addError(JAsmParseException.BAD_LOOKUP_ARGUMENT, arg, line); return 1; } if (args[0].trim().equals("default")) { return -1; } int b = Integer.parseInt(args[0].trim()); return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, arg, line); return 1; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.BAD_LOOKUP_ARGUMENT, arg, line); return 1; } } private int getLookupTarget(String arg, int line, int codeLength) { try { String[] args = arg.split(":"); if (args.length != 2) { parseException.addError(JAsmParseException.BAD_LOOKUP_ARGUMENT, arg, line); return 1; } int b = Integer.parseInt(args[1].trim()); if (b < 1 || b > codeLength) { parseException.addError(JAsmParseException.JUMP_OUT_OF_DOMAIN, arg, line); return 1; } return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, arg, line); return 1; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.BAD_LOOKUP_ARGUMENT, arg, line); return 1; } } private int countLines(String[] codeLines) { int count = 0; for (int i = 0; i < codeLines.length; i++) { if (!beginsWithWhitespace(codeLines[i])) { count++; } } return count; } private boolean beginsWithWhitespace(String line) { if (!line.equals("")) { if (line.charAt(0) == ' ' || line.charAt(0) == '\t') return true; } return false; } private int getTableArg(String arg, int line, int codeLength) { try { int i = Integer.parseInt(arg); if (i < 1 || i > codeLength) { parseException.addError(JAsmParseException.JUMP_OUT_OF_DOMAIN, arg, line); return 1; } return i; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, arg, line); return 1; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.INT_REQUIRED, arg, line); return 1; } } private int getJumpArg(String[] instrElems, int line, int codeLength) { try { int b = Integer.parseInt(instrElems[1]); if (b < 1 || b > codeLength) { parseException.addError(JAsmParseException.JUMP_OUT_OF_DOMAIN, instrElems[0], line); return 1; } return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 1; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.INT_REQUIRED, instrElems[0], line); return 1; } } private short getSingleShortArg(String[] instrElems, int line) { try { short b = Short.parseShort(instrElems[1]); return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.SHORT_REQUIRED, instrElems[0], line); return 0; } } private int getSingleIntArg(String[] instrElems, int line) { try { int b = Integer.parseInt(instrElems[1]); return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.INT_REQUIRED, instrElems[0], line); return 0; } } private byte getSingleByteArg(String[] instrElems, int line) { try { byte b = Byte.parseByte(instrElems[1]); return b; } catch (ArrayIndexOutOfBoundsException exc1) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } catch (NumberFormatException exc1) { parseException.addError(JAsmParseException.BYTE_REQUIRED, instrElems[0], line); return 0; } } private int getConstRefldc2_w(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } try { long larg = Long.parseLong(instrElems[1]); return cpg.addLong(larg); } catch (NumberFormatException nfei) { } try { double darg = Double.parseDouble(instrElems[1]); return cpg.addDouble(darg); } catch (NumberFormatException nfed) { } parseException.addError(JAsmParseException.ARG_TYPE_ERROR_LDC2_W, instrElems[0], line); return 0; } private byte getArrayRef(String[] instrElems, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } byte arg; try { arg = Byte.parseByte(instrElems[1]); } catch (NumberFormatException nfe) { arg = OpcodesUtil.getArrayType(instrElems[1]); if (arg == 0) { parseException.addError(JAsmParseException.ARG_TYPE_ERROR, instrElems[0], line); } } return arg; } private int getConstRef4ldc(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } try { int iarg = Integer.parseInt(instrElems[1]); return cpg.addInteger(iarg); } catch (NumberFormatException nfei) { } try { float farg = Float.parseFloat(instrElems[1]); return cpg.addFloat(farg); } catch (NumberFormatException nfed) { } if (instrElems[1].startsWith("\"")) { StringBuffer sb = new StringBuffer(instrElems[1]); for (int i = 2; i < instrElems.length; i++) { sb.append(" ").append(instrElems[i]); } String sarg = sb.toString(); if (sarg.startsWith("\"") && sarg.endsWith("\"")) { sarg = sarg.substring(1, sarg.length() - 1); return cpg.addString(sarg); } else { parseException.addError(JAsmParseException.ARG_TYPE_ERROR, instrElems[0], line); return 0; } } parseException.addError(JAsmParseException.ARG_TYPE_ERROR, instrElems[0], line); return 0; } private int getClassConstRef(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } int arg; try { arg = Integer.parseInt(instrElems[1]); } catch (NumberFormatException nfe) { String classN = instrElems[1]; arg = cpg.addClass(classN); } return arg; } private int getFieldConstRef(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 3) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } int arg; try { arg = Integer.parseInt(instrElems[1]); } catch (NumberFormatException nfe) { String classN = getClassFromFieldName(instrElems[1]); String fieldN = getFieldFromFieldName(instrElems[1]); String descr = instrElems[2]; arg = cpg.addFieldref(classN, fieldN, descr); } return arg; } private int getMethodConstRef(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } int arg; try { arg = Integer.parseInt(instrElems[1]); } catch (NumberFormatException nfe) { String classN = getClassFromFullMethod(instrElems[1]); String methodN = getMethodFromFullMethod(instrElems[1]); String descr = getDescrFromFullMethod(instrElems[1]); arg = cpg.addMethodref(classN, methodN, descr); } return arg; } private int getInterfaceConstRef(String[] instrElems, ConstantPoolGen cpg, int line) { if (instrElems.length < 2) { parseException.addError(JAsmParseException.MISSING_ARGUMENTS, instrElems[0], line); return 0; } int arg; try { arg = Integer.parseInt(instrElems[1]); } catch (NumberFormatException nfe) { String classN = getClassFromFullMethod(instrElems[1]); String methodN = getMethodFromFullMethod(instrElems[1]); String descr = getDescrFromFullMethod(instrElems[1]); arg = cpg.addInterfaceMethodref(classN, methodN, descr); } return arg; } public String getClassFromFullMethod(String fullMethod) { String classAndMeth = fullMethod.substring(0, fullMethod.indexOf('(')); String className = getClassFromFieldName(classAndMeth); return className; } public String getMethodFromFullMethod(String fullMethod) { String classAndMeth = fullMethod.substring(0, fullMethod.indexOf('(')); String methName = getFieldFromFieldName(classAndMeth); return methName; } public String getDescrFromFullMethod(String fullMethod) { String description = fullMethod.substring(fullMethod.indexOf('('), fullMethod.length()); return description; } public String getClassFromFieldName(String fieldName) { String className = fieldName.substring(0, fieldName.lastIndexOf('/')); return className.replace('/', '.'); } public String getFieldFromFieldName(String fieldName) { String field = fieldName.substring(fieldName.lastIndexOf('/') + 1, fieldName.length()); return field; } class BranchPair { int source, target; BranchPair(int s, int t) { source = s; target = t; } } class TempSwitchData { int type; // 1 - table, 2 - lookup int initialLab; ArrayList<BranchPair> branchPairs = new ArrayList<BranchPair>(); private InstructionHandle ih; public TempSwitchData(int type, int label) { this.type = type; initialLab = label; } public void setHandle(InstructionHandle ih) { this.ih = ih; } public void incInitialLab() { initialLab++; } public int getInitialLab() { return initialLab; } public ArrayList<BranchPair> getBranchPairs() { return branchPairs; } public TempSwitchData() { } public TempSwitchData(int type) { this.type = type; } } }
dubenju/javay
src/java/ee/ioc/cs/jbe/browser/codeedit/JAsmParser.java
Java
apache-2.0
51,962
[ 30522, 1013, 1008, 1008, 1008, 1013, 7427, 25212, 1012, 25941, 1012, 20116, 1012, 1046, 4783, 1012, 16602, 1012, 3642, 2098, 4183, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 9140, 30524, 2102, 1012, 29175, 27102, 29521, 1012, 24880, 16044, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.fasterxml.jackson.databind.node; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.NumberOutput; import com.fasterxml.jackson.databind.SerializerProvider; /** * Numeric node that contains simple 32-bit integer values. */ @SuppressWarnings("serial") public class IntNode extends NumericNode { // // // Let's cache small set of common value final static int MIN_CANONICAL = -1; final static int MAX_CANONICAL = 10; private final static IntNode[] CANONICALS; static { int count = MAX_CANONICAL - MIN_CANONICAL + 1; CANONICALS = new IntNode[count]; for (int i = 0; i < count; ++i) { CANONICALS[i] = new IntNode(MIN_CANONICAL + i); } } /** * Integer value this node contains */ protected final int _value; /* ************************************************ * Construction ************************************************ */ public IntNode(int v) { _value = v; } public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; } /* /********************************************************** /* BaseJsonNode extended API /********************************************************** */ @Override public JsonToken asToken() { return JsonToken.VALUE_NUMBER_INT; } @Override public JsonParser.NumberType numberType() { return JsonParser.NumberType.INT; } /* /********************************************************** /* Overrridden JsonNode methods /********************************************************** */ @Override public boolean isIntegralNumber() { return true; } @Override public boolean isInt() { return true; } @Override public boolean canConvertToInt() { return true; } @Override public boolean canConvertToLong() { return true; } @Override public Number numberValue() { return Integer.valueOf(_value); } @Override public short shortValue() { return (short) _value; } @Override public int intValue() { return _value; } @Override public long longValue() { return (long) _value; } @Override public float floatValue() { return (float) _value; } @Override public double doubleValue() { return (double) _value; } @Override public BigDecimal decimalValue() { return BigDecimal.valueOf(_value); } @Override public BigInteger bigIntegerValue() { return BigInteger.valueOf(_value); } @Override public String asText() { return NumberOutput.toString(_value); } @Override public boolean asBoolean(boolean defaultValue) { return _value != 0; } @Override public final void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber(_value); } @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o instanceof IntNode) { return ((IntNode) o)._value == _value; } return false; } @Override public int hashCode() { return _value; } }
FasterXML/jackson-databind
src/main/java/com/fasterxml/jackson/databind/node/IntNode.java
Java
apache-2.0
3,398
[ 30522, 7427, 4012, 1012, 5514, 2595, 19968, 1012, 4027, 1012, 2951, 8428, 2094, 1012, 13045, 1025, 12324, 9262, 1012, 22834, 1012, 22834, 10288, 24422, 1025, 12324, 9262, 1012, 8785, 1012, 2502, 3207, 6895, 9067, 1025, 12324, 9262, 1012, 87...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import sys sys.path.insert(1, "../../../") import h2o def link_functions_tweedie_basic(ip,port): # Connect to h2o h2o.init(ip,port) print "Read in prostate data." hdf = h2o.upload_file(h2o.locate("smalldata/prostate/prostate_complete.csv.zip")) print "Testing for family: TWEEDIE" print "Set variables for h2o." y = "CAPSULE" x = ["AGE","RACE","DCAPS","PSA","VOL","DPROS","GLEASON"] print "Create models with canonical link: TWEEDIE" model_h2o_tweedie = h2o.glm(x=hdf[x], y=hdf[y], family="tweedie", link="tweedie", alpha=[0.5], Lambda = [0]) print "Compare model deviances for link function tweedie (using precomputed values from R)" deviance_h2o_tweedie = model_h2o_tweedie.residual_deviance() / model_h2o_tweedie.null_deviance() assert 0.721452 - deviance_h2o_tweedie <= 0.01, "h2o's residual/null deviance is more than 0.01 lower than R's. h2o: " \ "{0}, r: {1}".format(deviance_h2o_tweedie, 0.721452) if __name__ == "__main__": h2o.run_test(sys.argv, link_functions_tweedie_basic)
ChristosChristofidis/h2o-3
h2o-py/tests/testdir_algos/glm/pyunit_link_functions_tweedie_basicGLM.py
Python
apache-2.0
1,103
[ 30522, 12324, 25353, 2015, 25353, 2015, 1012, 4130, 1012, 19274, 1006, 1015, 1010, 1000, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 1000, 1007, 12324, 1044, 2475, 2080, 13366, 4957, 1035, 4972, 1035, 26922, 2666, 1035, 3937, 1006...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.3.1"/> <title>Core3: /Users/victor/git/Core3Mda/MMOCoreORB/src/server/login/account Directory Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Core3 </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_075bb3ff235063c77951cd176d15a741.html">server</a></li><li class="navelem"><a class="el" href="dir_f1c565547ee022ddb47ac577f195d032.html">login</a></li><li class="navelem"><a class="el" href="dir_510a258b894cb471901d9a7057c265c6.html">account</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">account Directory Reference</div> </div> </div><!--header--> <div class="contents"> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="files"></a> Files</h2></td></tr> <tr class="memitem:_account_8cpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_8cpp.html">Account.cpp</a> <a href="_account_8cpp_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:_account_8h"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_8h.html">Account.h</a> <a href="_account_8h_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:_account_implementation_8cpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_implementation_8cpp.html">AccountImplementation.cpp</a> <a href="_account_implementation_8cpp_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:_account_manager_8cpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_manager_8cpp.html">AccountManager.cpp</a> <a href="_account_manager_8cpp_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:_account_manager_8h"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_manager_8h.html">AccountManager.h</a> <a href="_account_manager_8h_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:_account_map_8h"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_account_map_8h.html">AccountMap.h</a> <a href="_account_map_8h_source.html">[code]</a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Tue Oct 15 2013 17:30:14 for Core3 by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.3.1 </small></address> </body> </html>
kidaa/Awakening-Core3
doc/html/dir_510a258b894cb471901d9a7057c265c6.html
HTML
lgpl-3.0
4,561
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 30524, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, 19817, 1013, 1060, 11039, 19968,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> * Horst Hummel <Horst.Hummel@de.ibm.com> * Carsten Otte <Cotte@de.ibm.com> * Martin Schwidefsky <schwidefsky@de.ibm.com> * Bugreports.to..: <Linux390@de.ibm.com> * Copyright IBM Corp. 1999, 2009 */ #define KMSG_COMPONENT "dasd" #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include <linux/kmod.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/ctype.h> #include <linux/major.h> #include <linux/slab.h> #include <linux/hdreg.h> #include <linux/async.h> #include <linux/mutex.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/vmalloc.h> #include <asm/ccwdev.h> #include <asm/ebcdic.h> #include <asm/idals.h> #include <asm/itcw.h> #include <asm/diag.h> /* This is ugly... */ #define PRINTK_HEADER "dasd:" #include "dasd_int.h" /* * SECTION: Constant definitions to be used within this file */ #define DASD_CHANQ_MAX_SIZE 4 #define DASD_SLEEPON_START_TAG (void *) 1 #define DASD_SLEEPON_END_TAG (void *) 2 /* * SECTION: exported variables of dasd.c */ debug_info_t *dasd_debug_area; static struct dentry *dasd_debugfs_root_entry; struct dasd_discipline *dasd_diag_discipline_pointer; void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>"); MODULE_DESCRIPTION("Linux on S/390 DASD device driver," " Copyright IBM Corp. 2000"); MODULE_SUPPORTED_DEVICE("dasd"); MODULE_LICENSE("GPL"); /* * SECTION: prototypes for static functions of dasd.c */ static int dasd_alloc_queue(struct dasd_block *); static void dasd_setup_queue(struct dasd_block *); static void dasd_free_queue(struct dasd_block *); static void dasd_flush_request_queue(struct dasd_block *); static int dasd_flush_block_queue(struct dasd_block *); static void dasd_device_tasklet(struct dasd_device *); static void dasd_block_tasklet(struct dasd_block *); static void do_kick_device(struct work_struct *); static void do_restore_device(struct work_struct *); static void do_reload_device(struct work_struct *); static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *); static void dasd_device_timeout(unsigned long); static void dasd_block_timeout(unsigned long); static void __dasd_process_erp(struct dasd_device *, struct dasd_ccw_req *); static void dasd_profile_init(struct dasd_profile *, struct dentry *); static void dasd_profile_exit(struct dasd_profile *); /* * SECTION: Operations on the device structure. */ static wait_queue_head_t dasd_init_waitq; static wait_queue_head_t dasd_flush_wq; static wait_queue_head_t generic_waitq; static wait_queue_head_t shutdown_waitq; /* * Allocate memory for a new device structure. */ struct dasd_device *dasd_alloc_device(void) { struct dasd_device *device; device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC); if (!device) return ERR_PTR(-ENOMEM); /* Get two pages for normal block device operations. */ device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1); if (!device->ccw_mem) { kfree(device); return ERR_PTR(-ENOMEM); } /* Get one page for error recovery. */ device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA); if (!device->erp_mem) { free_pages((unsigned long) device->ccw_mem, 1); kfree(device); return ERR_PTR(-ENOMEM); } dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2); dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE); spin_lock_init(&device->mem_lock); atomic_set(&device->tasklet_scheduled, 0); tasklet_init(&device->tasklet, (void (*)(unsigned long)) dasd_device_tasklet, (unsigned long) device); INIT_LIST_HEAD(&device->ccw_queue); init_timer(&device->timer); device->timer.function = dasd_device_timeout; device->timer.data = (unsigned long) device; INIT_WORK(&device->kick_work, do_kick_device); INIT_WORK(&device->restore_device, do_restore_device); INIT_WORK(&device->reload_device, do_reload_device); device->state = DASD_STATE_NEW; device->target = DASD_STATE_NEW; mutex_init(&device->state_mutex); spin_lock_init(&device->profile.lock); return device; } /* * Free memory of a device structure. */ void dasd_free_device(struct dasd_device *device) { kfree(device->private); free_page((unsigned long) device->erp_mem); free_pages((unsigned long) device->ccw_mem, 1); kfree(device); } /* * Allocate memory for a new device structure. */ struct dasd_block *dasd_alloc_block(void) { struct dasd_block *block; block = kzalloc(sizeof(*block), GFP_ATOMIC); if (!block) return ERR_PTR(-ENOMEM); /* open_count = 0 means device online but not in use */ atomic_set(&block->open_count, -1); spin_lock_init(&block->request_queue_lock); atomic_set(&block->tasklet_scheduled, 0); tasklet_init(&block->tasklet, (void (*)(unsigned long)) dasd_block_tasklet, (unsigned long) block); INIT_LIST_HEAD(&block->ccw_queue); spin_lock_init(&block->queue_lock); init_timer(&block->timer); block->timer.function = dasd_block_timeout; block->timer.data = (unsigned long) block; spin_lock_init(&block->profile.lock); return block; } /* * Free memory of a device structure. */ void dasd_free_block(struct dasd_block *block) { kfree(block); } /* * Make a new device known to the system. */ static int dasd_state_new_to_known(struct dasd_device *device) { int rc; /* * As long as the device is not in state DASD_STATE_NEW we want to * keep the reference count > 0. */ dasd_get_device(device); if (device->block) { rc = dasd_alloc_queue(device->block); if (rc) { dasd_put_device(device); return rc; } } device->state = DASD_STATE_KNOWN; return 0; } /* * Let the system forget about a device. */ static int dasd_state_known_to_new(struct dasd_device *device) { /* Disable extended error reporting for this device. */ dasd_eer_disable(device); /* Forget the discipline information. */ if (device->discipline) { if (device->discipline->uncheck_device) device->discipline->uncheck_device(device); module_put(device->discipline->owner); } device->discipline = NULL; if (device->base_discipline) module_put(device->base_discipline->owner); device->base_discipline = NULL; device->state = DASD_STATE_NEW; if (device->block) dasd_free_queue(device->block); /* Give up reference we took in dasd_state_new_to_known. */ dasd_put_device(device); return 0; } static struct dentry *dasd_debugfs_setup(const char *name, struct dentry *base_dentry) { struct dentry *pde; if (!base_dentry) return NULL; pde = debugfs_create_dir(name, base_dentry); if (!pde || IS_ERR(pde)) return NULL; return pde; } /* * Request the irq line for the device. */ static int dasd_state_known_to_basic(struct dasd_device *device) { struct dasd_block *block = device->block; int rc = 0; /* Allocate and register gendisk structure. */ if (block) { rc = dasd_gendisk_alloc(block); if (rc) return rc; block->debugfs_dentry = dasd_debugfs_setup(block->gdp->disk_name, dasd_debugfs_root_entry); dasd_profile_init(&block->profile, block->debugfs_dentry); if (dasd_global_profile_level == DASD_PROFILE_ON) dasd_profile_on(&device->block->profile); } device->debugfs_dentry = dasd_debugfs_setup(dev_name(&device->cdev->dev), dasd_debugfs_root_entry); dasd_profile_init(&device->profile, device->debugfs_dentry); /* register 'device' debug area, used for all DBF_DEV_XXX calls */ device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1, 8 * sizeof(long)); debug_register_view(device->debug_area, &debug_sprintf_view); debug_set_level(device->debug_area, DBF_WARNING); DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created"); device->state = DASD_STATE_BASIC; return rc; } /* * Release the irq line for the device. Terminate any running i/o. */ static int dasd_state_basic_to_known(struct dasd_device *device) { int rc; if (device->discipline->basic_to_known) { rc = device->discipline->basic_to_known(device); if (rc) return rc; } if (device->block) { dasd_profile_exit(&device->block->profile); if (device->block->debugfs_dentry) debugfs_remove(device->block->debugfs_dentry); dasd_gendisk_free(device->block); dasd_block_clear_timer(device->block); } rc = dasd_flush_device_queue(device); if (rc) return rc; dasd_device_clear_timer(device); dasd_profile_exit(&device->profile); if (device->debugfs_dentry) debugfs_remove(device->debugfs_dentry); DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); if (device->debug_area != NULL) { debug_unregister(device->debug_area); device->debug_area = NULL; } device->state = DASD_STATE_KNOWN; return 0; } /* * Do the initial analysis. The do_analysis function may return * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC * until the discipline decides to continue the startup sequence * by calling the function dasd_change_state. The eckd disciplines * uses this to start a ccw that detects the format. The completion * interrupt for this detection ccw uses the kernel event daemon to * trigger the call to dasd_change_state. All this is done in the * discipline code, see dasd_eckd.c. * After the analysis ccw is done (do_analysis returned 0) the block * device is setup. * In case the analysis returns an error, the device setup is stopped * (a fake disk was already added to allow formatting). */ static int dasd_state_basic_to_ready(struct dasd_device *device) { int rc; struct dasd_block *block; rc = 0; block = device->block; /* make disk known with correct capacity */ if (block) { if (block->base->discipline->do_analysis != NULL) rc = block->base->discipline->do_analysis(block); if (rc) { if (rc != -EAGAIN) { device->state = DASD_STATE_UNFMT; goto out; } return rc; } dasd_setup_queue(block); set_capacity(block->gdp, block->blocks << block->s2b_shift); device->state = DASD_STATE_READY; rc = dasd_scan_partitions(block); if (rc) { device->state = DASD_STATE_BASIC; return rc; } } else { device->state = DASD_STATE_READY; } out: if (device->discipline->basic_to_ready) rc = device->discipline->basic_to_ready(device); return rc; } static inline int _wait_for_empty_queues(struct dasd_device *device) { if (device->block) return list_empty(&device->ccw_queue) && list_empty(&device->block->ccw_queue); else return list_empty(&device->ccw_queue); } /* * Remove device from block device layer. Destroy dirty buffers. * Forget format information. Check if the target level is basic * and if it is create fake disk for formatting. */ static int dasd_state_ready_to_basic(struct dasd_device *device) { int rc; device->state = DASD_STATE_BASIC; if (device->block) { struct dasd_block *block = device->block; rc = dasd_flush_block_queue(block); if (rc) { device->state = DASD_STATE_READY; return rc; } dasd_flush_request_queue(block); dasd_destroy_partitions(block); block->blocks = 0; block->bp_block = 0; block->s2b_shift = 0; } return 0; } /* * Back to basic. */ static int dasd_state_unfmt_to_basic(struct dasd_device *device) { device->state = DASD_STATE_BASIC; return 0; } /* * Make the device online and schedule the bottom half to start * the requeueing of requests from the linux request queue to the * ccw queue. */ static int dasd_state_ready_to_online(struct dasd_device * device) { struct gendisk *disk; struct disk_part_iter piter; struct hd_struct *part; device->state = DASD_STATE_ONLINE; if (device->block) { dasd_schedule_block_bh(device->block); if ((device->features & DASD_FEATURE_USERAW)) { disk = device->block->gdp; kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); return 0; } disk = device->block->bdev->bd_disk; disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); while ((part = disk_part_iter_next(&piter))) kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); disk_part_iter_exit(&piter); } return 0; } /* * Stop the requeueing of requests again. */ static int dasd_state_online_to_ready(struct dasd_device *device) { int rc; struct gendisk *disk; struct disk_part_iter piter; struct hd_struct *part; if (device->discipline->online_to_ready) { rc = device->discipline->online_to_ready(device); if (rc) return rc; } device->state = DASD_STATE_READY; if (device->block && !(device->features & DASD_FEATURE_USERAW)) { disk = device->block->bdev->bd_disk; disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); while ((part = disk_part_iter_next(&piter))) kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); disk_part_iter_exit(&piter); } return 0; } /* * Device startup state changes. */ static int dasd_increase_state(struct dasd_device *device) { int rc; rc = 0; if (device->state == DASD_STATE_NEW && device->target >= DASD_STATE_KNOWN) rc = dasd_state_new_to_known(device); if (!rc && device->state == DASD_STATE_KNOWN && device->target >= DASD_STATE_BASIC) rc = dasd_state_known_to_basic(device); if (!rc && device->state == DASD_STATE_BASIC && device->target >= DASD_STATE_READY) rc = dasd_state_basic_to_ready(device); if (!rc && device->state == DASD_STATE_UNFMT && device->target > DASD_STATE_UNFMT) rc = -EPERM; if (!rc && device->state == DASD_STATE_READY && device->target >= DASD_STATE_ONLINE) rc = dasd_state_ready_to_online(device); return rc; } /* * Device shutdown state changes. */ static int dasd_decrease_state(struct dasd_device *device) { int rc; rc = 0; if (device->state == DASD_STATE_ONLINE && device->target <= DASD_STATE_READY) rc = dasd_state_online_to_ready(device); if (!rc && device->state == DASD_STATE_READY && device->target <= DASD_STATE_BASIC) rc = dasd_state_ready_to_basic(device); if (!rc && device->state == DASD_STATE_UNFMT && device->target <= DASD_STATE_BASIC) rc = dasd_state_unfmt_to_basic(device); if (!rc && device->state == DASD_STATE_BASIC && device->target <= DASD_STATE_KNOWN) rc = dasd_state_basic_to_known(device); if (!rc && device->state == DASD_STATE_KNOWN && device->target <= DASD_STATE_NEW) rc = dasd_state_known_to_new(device); return rc; } /* * This is the main startup/shutdown routine. */ static void dasd_change_state(struct dasd_device *device) { int rc; if (device->state == device->target) /* Already where we want to go today... */ return; if (device->state < device->target) rc = dasd_increase_state(device); else rc = dasd_decrease_state(device); if (rc == -EAGAIN) return; if (rc) device->target = device->state; /* let user-space know that the device status changed */ kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); if (device->state == device->target) wake_up(&dasd_init_waitq); } /* * Kick starter for devices that did not complete the startup/shutdown * procedure or were sleeping because of a pending state. * dasd_kick_device will schedule a call do do_kick_device to the kernel * event daemon. */ static void do_kick_device(struct work_struct *work) { struct dasd_device *device = container_of(work, struct dasd_device, kick_work); mutex_lock(&device->state_mutex); dasd_change_state(device); mutex_unlock(&device->state_mutex); dasd_schedule_device_bh(device); dasd_put_device(device); } void dasd_kick_device(struct dasd_device *device) { dasd_get_device(device); /* queue call to dasd_kick_device to the kernel event daemon. */ if (!schedule_work(&device->kick_work)) dasd_put_device(device); } /* * dasd_reload_device will schedule a call do do_reload_device to the kernel * event daemon. */ static void do_reload_device(struct work_struct *work) { struct dasd_device *device = container_of(work, struct dasd_device, reload_device); device->discipline->reload(device); dasd_put_device(device); } void dasd_reload_device(struct dasd_device *device) { dasd_get_device(device); /* queue call to dasd_reload_device to the kernel event daemon. */ if (!schedule_work(&device->reload_device)) dasd_put_device(device); } EXPORT_SYMBOL(dasd_reload_device); /* * dasd_restore_device will schedule a call do do_restore_device to the kernel * event daemon. */ static void do_restore_device(struct work_struct *work) { struct dasd_device *device = container_of(work, struct dasd_device, restore_device); device->cdev->drv->restore(device->cdev); dasd_put_device(device); } void dasd_restore_device(struct dasd_device *device) { dasd_get_device(device); /* queue call to dasd_restore_device to the kernel event daemon. */ if (!schedule_work(&device->restore_device)) dasd_put_device(device); } /* * Set the target state for a device and starts the state change. */ void dasd_set_target_state(struct dasd_device *device, int target) { dasd_get_device(device); mutex_lock(&device->state_mutex); /* If we are in probeonly mode stop at DASD_STATE_READY. */ if (dasd_probeonly && target > DASD_STATE_READY) target = DASD_STATE_READY; if (device->target != target) { if (device->state == target) wake_up(&dasd_init_waitq); device->target = target; } if (device->state != device->target) dasd_change_state(device); mutex_unlock(&device->state_mutex); dasd_put_device(device); } /* * Enable devices with device numbers in [from..to]. */ static inline int _wait_for_device(struct dasd_device *device) { return (device->state == device->target); } void dasd_enable_device(struct dasd_device *device) { dasd_set_target_state(device, DASD_STATE_ONLINE); if (device->state <= DASD_STATE_KNOWN) /* No discipline for device found. */ dasd_set_target_state(device, DASD_STATE_NEW); /* Now wait for the devices to come up. */ wait_event(dasd_init_waitq, _wait_for_device(device)); dasd_reload_device(device); if (device->discipline->kick_validate) device->discipline->kick_validate(device); } /* * SECTION: device operation (interrupt handler, start i/o, term i/o ...) */ unsigned int dasd_global_profile_level = DASD_PROFILE_OFF; #ifdef CONFIG_DASD_PROFILE struct dasd_profile_info dasd_global_profile_data; static struct dentry *dasd_global_profile_dentry; static struct dentry *dasd_debugfs_global_entry; /* * Add profiling information for cqr before execution. */ static void dasd_profile_start(struct dasd_block *block, struct dasd_ccw_req *cqr, struct request *req) { struct list_head *l; unsigned int counter; struct dasd_device *device; /* count the length of the chanq for statistics */ counter = 0; if (dasd_global_profile_level || block->profile.data) list_for_each(l, &block->ccw_queue) if (++counter >= 31) break; if (dasd_global_profile_level) { dasd_global_profile_data.dasd_io_nr_req[counter]++; if (rq_data_dir(req) == READ) dasd_global_profile_data.dasd_read_nr_req[counter]++; } spin_lock(&block->profile.lock); if (block->profile.data) block->profile.data->dasd_io_nr_req[counter]++; if (rq_data_dir(req) == READ) block->profile.data->dasd_read_nr_req[counter]++; spin_unlock(&block->profile.lock); /* * We count the request for the start device, even though it may run on * some other device due to error recovery. This way we make sure that * we count each request only once. */ device = cqr->startdev; if (device->profile.data) { counter = 1; /* request is not yet queued on the start device */ list_for_each(l, &device->ccw_queue) if (++counter >= 31) break; } spin_lock(&device->profile.lock); if (device->profile.data) { device->profile.data->dasd_io_nr_req[counter]++; if (rq_data_dir(req) == READ) device->profile.data->dasd_read_nr_req[counter]++; } spin_unlock(&device->profile.lock); } /* * Add profiling information for cqr after execution. */ #define dasd_profile_counter(value, index) \ { \ for (index = 0; index < 31 && value >> (2+index); index++) \ ; \ } static void dasd_profile_end_add_data(struct dasd_profile_info *data, int is_alias, int is_tpm, int is_read, long sectors, int sectors_ind, int tottime_ind, int tottimeps_ind, int strtime_ind, int irqtime_ind, int irqtimeps_ind, int endtime_ind) { /* in case of an overflow, reset the whole profile */ if (data->dasd_io_reqs == UINT_MAX) { memset(data, 0, sizeof(*data)); getnstimeofday(&data->starttod); } data->dasd_io_reqs++; data->dasd_io_sects += sectors; if (is_alias) data->dasd_io_alias++; if (is_tpm) data->dasd_io_tpm++; data->dasd_io_secs[sectors_ind]++; data->dasd_io_times[tottime_ind]++; data->dasd_io_timps[tottimeps_ind]++; data->dasd_io_time1[strtime_ind]++; data->dasd_io_time2[irqtime_ind]++; data->dasd_io_time2ps[irqtimeps_ind]++; data->dasd_io_time3[endtime_ind]++; if (is_read) { data->dasd_read_reqs++; data->dasd_read_sects += sectors; if (is_alias) data->dasd_read_alias++; if (is_tpm) data->dasd_read_tpm++; data->dasd_read_secs[sectors_ind]++; data->dasd_read_times[tottime_ind]++; data->dasd_read_time1[strtime_ind]++; data->dasd_read_time2[irqtime_ind]++; data->dasd_read_time3[endtime_ind]++; } } static void dasd_profile_end(struct dasd_block *block, struct dasd_ccw_req *cqr, struct request *req) { long strtime, irqtime, endtime, tottime; /* in microseconds */ long tottimeps, sectors; struct dasd_device *device; int sectors_ind, tottime_ind, tottimeps_ind, strtime_ind; int irqtime_ind, irqtimeps_ind, endtime_ind; device = cqr->startdev; if (!(dasd_global_profile_level || block->profile.data || device->profile.data)) return; sectors = blk_rq_sectors(req); if (!cqr->buildclk || !cqr->startclk || !cqr->stopclk || !cqr->endclk || !sectors) return; strtime = ((cqr->startclk - cqr->buildclk) >> 12); irqtime = ((cqr->stopclk - cqr->startclk) >> 12); endtime = ((cqr->endclk - cqr->stopclk) >> 12); tottime = ((cqr->endclk - cqr->buildclk) >> 12); tottimeps = tottime / sectors; dasd_profile_counter(sectors, sectors_ind); dasd_profile_counter(tottime, tottime_ind); dasd_profile_counter(tottimeps, tottimeps_ind); dasd_profile_counter(strtime, strtime_ind); dasd_profile_counter(irqtime, irqtime_ind); dasd_profile_counter(irqtime / sectors, irqtimeps_ind); dasd_profile_counter(endtime, endtime_ind); if (dasd_global_profile_level) { dasd_profile_end_add_data(&dasd_global_profile_data, cqr->startdev != block->base, cqr->cpmode == 1, rq_data_dir(req) == READ, sectors, sectors_ind, tottime_ind, tottimeps_ind, strtime_ind, irqtime_ind, irqtimeps_ind, endtime_ind); } spin_lock(&block->profile.lock); if (block->profile.data) dasd_profile_end_add_data(block->profile.data, cqr->startdev != block->base, cqr->cpmode == 1, rq_data_dir(req) == READ, sectors, sectors_ind, tottime_ind, tottimeps_ind, strtime_ind, irqtime_ind, irqtimeps_ind, endtime_ind); spin_unlock(&block->profile.lock); spin_lock(&device->profile.lock); if (device->profile.data) dasd_profile_end_add_data(device->profile.data, cqr->startdev != block->base, cqr->cpmode == 1, rq_data_dir(req) == READ, sectors, sectors_ind, tottime_ind, tottimeps_ind, strtime_ind, irqtime_ind, irqtimeps_ind, endtime_ind); spin_unlock(&device->profile.lock); } void dasd_profile_reset(struct dasd_profile *profile) { struct dasd_profile_info *data; spin_lock_bh(&profile->lock); data = profile->data; if (!data) { spin_unlock_bh(&profile->lock); return; } memset(data, 0, sizeof(*data)); getnstimeofday(&data->starttod); spin_unlock_bh(&profile->lock); } void dasd_global_profile_reset(void) { memset(&dasd_global_profile_data, 0, sizeof(dasd_global_profile_data)); getnstimeofday(&dasd_global_profile_data.starttod); } int dasd_profile_on(struct dasd_profile *profile) { struct dasd_profile_info *data; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; spin_lock_bh(&profile->lock); if (profile->data) { spin_unlock_bh(&profile->lock); kfree(data); return 0; } getnstimeofday(&data->starttod); profile->data = data; spin_unlock_bh(&profile->lock); return 0; } void dasd_profile_off(struct dasd_profile *profile) { spin_lock_bh(&profile->lock); kfree(profile->data); profile->data = NULL; spin_unlock_bh(&profile->lock); } char *dasd_get_user_string(const char __user *user_buf, size_t user_len) { char *buffer; buffer = vmalloc(user_len + 1); if (buffer == NULL) return ERR_PTR(-ENOMEM); if (copy_from_user(buffer, user_buf, user_len) != 0) { vfree(buffer); return ERR_PTR(-EFAULT); } /* got the string, now strip linefeed. */ if (buffer[user_len - 1] == '\n') buffer[user_len - 1] = 0; else buffer[user_len] = 0; return buffer; } static ssize_t dasd_stats_write(struct file *file, const char __user *user_buf, size_t user_len, loff_t *pos) { char *buffer, *str; int rc; struct seq_file *m = (struct seq_file *)file->private_data; struct dasd_profile *prof = m->private; if (user_len > 65536) user_len = 65536; buffer = dasd_get_user_string(user_buf, user_len); if (IS_ERR(buffer)) return PTR_ERR(buffer); str = skip_spaces(buffer); rc = user_len; if (strncmp(str, "reset", 5) == 0) { dasd_profile_reset(prof); } else if (strncmp(str, "on", 2) == 0) { rc = dasd_profile_on(prof); if (!rc) rc = user_len; } else if (strncmp(str, "off", 3) == 0) { dasd_profile_off(prof); } else rc = -EINVAL; vfree(buffer); return rc; } static void dasd_stats_array(struct seq_file *m, unsigned int *array) { int i; for (i = 0; i < 32; i++) seq_printf(m, "%u ", array[i]); seq_putc(m, '\n'); } static void dasd_stats_seq_print(struct seq_file *m, struct dasd_profile_info *data) { seq_printf(m, "start_time %ld.%09ld\n", data->starttod.tv_sec, data->starttod.tv_nsec); seq_printf(m, "total_requests %u\n", data->dasd_io_reqs); seq_printf(m, "total_sectors %u\n", data->dasd_io_sects); seq_printf(m, "total_pav %u\n", data->dasd_io_alias); seq_printf(m, "total_hpf %u\n", data->dasd_io_tpm); seq_printf(m, "histogram_sectors "); dasd_stats_array(m, data->dasd_io_secs); seq_printf(m, "histogram_io_times "); dasd_stats_array(m, data->dasd_io_times); seq_printf(m, "histogram_io_times_weighted "); dasd_stats_array(m, data->dasd_io_timps); seq_printf(m, "histogram_time_build_to_ssch "); dasd_stats_array(m, data->dasd_io_time1); seq_printf(m, "histogram_time_ssch_to_irq "); dasd_stats_array(m, data->dasd_io_time2); seq_printf(m, "histogram_time_ssch_to_irq_weighted "); dasd_stats_array(m, data->dasd_io_time2ps); seq_printf(m, "histogram_time_irq_to_end "); dasd_stats_array(m, data->dasd_io_time3); seq_printf(m, "histogram_ccw_queue_length "); dasd_stats_array(m, data->dasd_io_nr_req); seq_printf(m, "total_read_requests %u\n", data->dasd_read_reqs); seq_printf(m, "total_read_sectors %u\n", data->dasd_read_sects); seq_printf(m, "total_read_pav %u\n", data->dasd_read_alias); seq_printf(m, "total_read_hpf %u\n", data->dasd_read_tpm); seq_printf(m, "histogram_read_sectors "); dasd_stats_array(m, data->dasd_read_secs); seq_printf(m, "histogram_read_times "); dasd_stats_array(m, data->dasd_read_times); seq_printf(m, "histogram_read_time_build_to_ssch "); dasd_stats_array(m, data->dasd_read_time1); seq_printf(m, "histogram_read_time_ssch_to_irq "); dasd_stats_array(m, data->dasd_read_time2); seq_printf(m, "histogram_read_time_irq_to_end "); dasd_stats_array(m, data->dasd_read_time3); seq_printf(m, "histogram_read_ccw_queue_length "); dasd_stats_array(m, data->dasd_read_nr_req); } static int dasd_stats_show(struct seq_file *m, void *v) { struct dasd_profile *profile; struct dasd_profile_info *data; profile = m->private; spin_lock_bh(&profile->lock); data = profile->data; if (!data) { spin_unlock_bh(&profile->lock); seq_printf(m, "disabled\n"); return 0; } dasd_stats_seq_print(m, data); spin_unlock_bh(&profile->lock); return 0; } static int dasd_stats_open(struct inode *inode, struct file *file) { struct dasd_profile *profile = inode->i_private; return single_open(file, dasd_stats_show, profile); } static const struct file_operations dasd_stats_raw_fops = { .owner = THIS_MODULE, .open = dasd_stats_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = dasd_stats_write, }; static ssize_t dasd_stats_global_write(struct file *file, const char __user *user_buf, size_t user_len, loff_t *pos) { char *buffer, *str; ssize_t rc; if (user_len > 65536) user_len = 65536; buffer = dasd_get_user_string(user_buf, user_len); if (IS_ERR(buffer)) return PTR_ERR(buffer); str = skip_spaces(buffer); rc = user_len; if (strncmp(str, "reset", 5) == 0) { dasd_global_profile_reset(); } else if (strncmp(str, "on", 2) == 0) { dasd_global_profile_reset(); dasd_global_profile_level = DASD_PROFILE_GLOBAL_ONLY; } else if (strncmp(str, "off", 3) == 0) { dasd_global_profile_level = DASD_PROFILE_OFF; } else rc = -EINVAL; vfree(buffer); return rc; } static int dasd_stats_global_show(struct seq_file *m, void *v) { if (!dasd_global_profile_level) { seq_printf(m, "disabled\n"); return 0; } dasd_stats_seq_print(m, &dasd_global_profile_data); return 0; } static int dasd_stats_global_open(struct inode *inode, struct file *file) { return single_open(file, dasd_stats_global_show, NULL); } static const struct file_operations dasd_stats_global_fops = { .owner = THIS_MODULE, .open = dasd_stats_global_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = dasd_stats_global_write, }; static void dasd_profile_init(struct dasd_profile *profile, struct dentry *base_dentry) { umode_t mode; struct dentry *pde; if (!base_dentry) return; profile->dentry = NULL; profile->data = NULL; mode = (S_IRUSR | S_IWUSR | S_IFREG); pde = debugfs_create_file("statistics", mode, base_dentry, profile, &dasd_stats_raw_fops); if (pde && !IS_ERR(pde)) profile->dentry = pde; return; } static void dasd_profile_exit(struct dasd_profile *profile) { dasd_profile_off(profile); if (profile->dentry) { debugfs_remove(profile->dentry); profile->dentry = NULL; } } static void dasd_statistics_removeroot(void) { dasd_global_profile_level = DASD_PROFILE_OFF; if (dasd_global_profile_dentry) { debugfs_remove(dasd_global_profile_dentry); dasd_global_profile_dentry = NULL; } if (dasd_debugfs_global_entry) debugfs_remove(dasd_debugfs_global_entry); if (dasd_debugfs_root_entry) debugfs_remove(dasd_debugfs_root_entry); } static void dasd_statistics_createroot(void) { umode_t mode; struct dentry *pde; dasd_debugfs_root_entry = NULL; dasd_debugfs_global_entry = NULL; dasd_global_profile_dentry = NULL; pde = debugfs_create_dir("dasd", NULL); if (!pde || IS_ERR(pde)) goto error; dasd_debugfs_root_entry = pde; pde = debugfs_create_dir("global", dasd_debugfs_root_entry); if (!pde || IS_ERR(pde)) goto error; dasd_debugfs_global_entry = pde; mode = (S_IRUSR | S_IWUSR | S_IFREG); pde = debugfs_create_file("statistics", mode, dasd_debugfs_global_entry, NULL, &dasd_stats_global_fops); if (!pde || IS_ERR(pde)) goto error; dasd_global_profile_dentry = pde; return; error: DBF_EVENT(DBF_ERR, "%s", "Creation of the dasd debugfs interface failed"); dasd_statistics_removeroot(); return; } #else #define dasd_profile_start(block, cqr, req) do {} while (0) #define dasd_profile_end(block, cqr, req) do {} while (0) static void dasd_statistics_createroot(void) { return; } static void dasd_statistics_removeroot(void) { return; } int dasd_stats_generic_show(struct seq_file *m, void *v) { seq_printf(m, "Statistics are not activated in this kernel\n"); return 0; } static void dasd_profile_init(struct dasd_profile *profile, struct dentry *base_dentry) { return; } static void dasd_profile_exit(struct dasd_profile *profile) { return; } int dasd_profile_on(struct dasd_profile *profile) { return 0; } #endif /* CONFIG_DASD_PROFILE */ /* * Allocate memory for a channel program with 'cplength' channel * command words and 'datasize' additional space. There are two * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed * memory and 2) dasd_smalloc_request uses the static ccw memory * that gets allocated for each device. */ struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength, int datasize, struct dasd_device *device) { struct dasd_ccw_req *cqr; /* Sanity checks */ BUG_ON(datasize > PAGE_SIZE || (cplength*sizeof(struct ccw1)) > PAGE_SIZE); cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC); if (cqr == NULL) return ERR_PTR(-ENOMEM); cqr->cpaddr = NULL; if (cplength > 0) { cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1), GFP_ATOMIC | GFP_DMA); if (cqr->cpaddr == NULL) { kfree(cqr); return ERR_PTR(-ENOMEM); } } cqr->data = NULL; if (datasize > 0) { cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA); if (cqr->data == NULL) { kfree(cqr->cpaddr); kfree(cqr); return ERR_PTR(-ENOMEM); } } cqr->magic = magic; set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); dasd_get_device(device); return cqr; } struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize, struct dasd_device *device) { unsigned long flags; struct dasd_ccw_req *cqr; char *data; int size; size = (sizeof(struct dasd_ccw_req) + 7L) & -8L; if (cplength > 0) size += cplength * sizeof(struct ccw1); if (datasize > 0) size += datasize; spin_lock_irqsave(&device->mem_lock, flags); cqr = (struct dasd_ccw_req *) dasd_alloc_chunk(&device->ccw_chunks, size); spin_unlock_irqrestore(&device->mem_lock, flags); if (cqr == NULL) return ERR_PTR(-ENOMEM); memset(cqr, 0, sizeof(struct dasd_ccw_req)); data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L); cqr->cpaddr = NULL; if (cplength > 0) { cqr->cpaddr = (struct ccw1 *) data; data += cplength*sizeof(struct ccw1); memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1)); } cqr->data = NULL; if (datasize > 0) { cqr->data = data; memset(cqr->data, 0, datasize); } cqr->magic = magic; set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); dasd_get_device(device); return cqr; } /* * Free memory of a channel program. This function needs to free all the * idal lists that might have been created by dasd_set_cda and the * struct dasd_ccw_req itself. */ void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) { #ifdef CONFIG_64BIT struct ccw1 *ccw; /* Clear any idals used for the request. */ ccw = cqr->cpaddr; do { clear_normalized_cda(ccw); } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC)); #endif kfree(cqr->cpaddr); kfree(cqr->data); kfree(cqr); dasd_put_device(device); } void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) { unsigned long flags; spin_lock_irqsave(&device->mem_lock, flags); dasd_free_chunk(&device->ccw_chunks, cqr); spin_unlock_irqrestore(&device->mem_lock, flags); dasd_put_device(device); } /* * Check discipline magic in cqr. */ static inline int dasd_check_cqr(struct dasd_ccw_req *cqr) { struct dasd_device *device; if (cqr == NULL) return -EINVAL; device = cqr->startdev; if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { DBF_DEV_EVENT(DBF_WARNING, device, " dasd_ccw_req 0x%08x magic doesn't match" " discipline 0x%08x", cqr->magic, *(unsigned int *) device->discipline->name); return -EINVAL; } return 0; } /* * Terminate the current i/o and set the request to clear_pending. * Timer keeps device runnig. * ccw_device_clear can fail if the i/o subsystem * is in a bad mood. */ int dasd_term_IO(struct dasd_ccw_req *cqr) { struct dasd_device *device; int retries, rc; char errorstring[ERRORLENGTH]; /* Check the cqr */ rc = dasd_check_cqr(cqr); if (rc) return rc; retries = 0; device = (struct dasd_device *) cqr->startdev; while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) { rc = ccw_device_clear(device->cdev, (long) cqr); switch (rc) { case 0: /* termination successful */ cqr->status = DASD_CQR_CLEAR_PENDING; cqr->stopclk = get_tod_clock(); cqr->starttime = 0; DBF_DEV_EVENT(DBF_DEBUG, device, "terminate cqr %p successful", cqr); break; case -ENODEV: DBF_DEV_EVENT(DBF_ERR, device, "%s", "device gone, retry"); break; case -EIO: DBF_DEV_EVENT(DBF_ERR, device, "%s", "I/O error, retry"); break; case -EINVAL: case -EBUSY: DBF_DEV_EVENT(DBF_ERR, device, "%s", "device busy, retry later"); break; default: /* internal error 10 - unknown rc*/ snprintf(errorstring, ERRORLENGTH, "10 %d", rc); dev_err(&device->cdev->dev, "An error occurred in the " "DASD device driver, reason=%s\n", errorstring); BUG(); break; } retries++; } dasd_schedule_device_bh(device); return rc; } /* * Start the i/o. This start_IO can fail if the channel is really busy. * In that case set up a timer to start the request later. */ int dasd_start_IO(struct dasd_ccw_req *cqr) { struct dasd_device *device; int rc; char errorstring[ERRORLENGTH]; /* Check the cqr */ rc = dasd_check_cqr(cqr); if (rc) { cqr->intrc = rc; return rc; } device = (struct dasd_device *) cqr->startdev; if (((cqr->block && test_bit(DASD_FLAG_LOCK_STOLEN, &cqr->block->base->flags)) || test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) && !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { DBF_DEV_EVENT(DBF_DEBUG, device, "start_IO: return request %p " "because of stolen lock", cqr); cqr->status = DASD_CQR_ERROR; cqr->intrc = -EPERM; return -EPERM; } if (cqr->retries < 0) { /* internal error 14 - start_IO run out of retries */ sprintf(errorstring, "14 %p", cqr); dev_err(&device->cdev->dev, "An error occurred in the DASD " "device driver, reason=%s\n", errorstring); cqr->status = DASD_CQR_ERROR; return -EIO; } cqr->startclk = get_tod_clock(); cqr->starttime = jiffies; cqr->retries--; if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { cqr->lpm &= device->path_data.opm; if (!cqr->lpm) cqr->lpm = device->path_data.opm; } if (cqr->cpmode == 1) { rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, (long) cqr, cqr->lpm); } else { rc = ccw_device_start(device->cdev, cqr->cpaddr, (long) cqr, cqr->lpm, 0); } switch (rc) { case 0: cqr->status = DASD_CQR_IN_IO; break; case -EBUSY: DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: device busy, retry later"); break; case -ETIMEDOUT: DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: request timeout, retry later"); break; case -EACCES: /* -EACCES indicates that the request used only a subset of the * available paths and all these paths are gone. If the lpm of * this request was only a subset of the opm (e.g. the ppm) then * we just do a retry with all available paths. * If we already use the full opm, something is amiss, and we * need a full path verification. */ if (test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { DBF_DEV_EVENT(DBF_WARNING, device, "start_IO: selected paths gone (%x)", cqr->lpm); } else if (cqr->lpm != device->path_data.opm) { cqr->lpm = device->path_data.opm; DBF_DEV_EVENT(DBF_DEBUG, device, "%s", "start_IO: selected paths gone," " retry on all paths"); } else { DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: all paths in opm gone," " do path verification"); dasd_generic_last_path_gone(device); device->path_data.opm = 0; device->path_data.ppm = 0; device->path_data.npm = 0; device->path_data.tbvpm = ccw_device_get_path_mask(device->cdev); } break; case -ENODEV: DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: -ENODEV device gone, retry"); break; case -EIO: DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: -EIO device gone, retry"); break; case -EINVAL: /* most likely caused in power management context */ DBF_DEV_EVENT(DBF_WARNING, device, "%s", "start_IO: -EINVAL device currently " "not accessible"); break; default: /* internal error 11 - unknown rc */ snprintf(errorstring, ERRORLENGTH, "11 %d", rc); dev_err(&device->cdev->dev, "An error occurred in the DASD device driver, " "reason=%s\n", errorstring); BUG(); break; } cqr->intrc = rc; return rc; } /* * Timeout function for dasd devices. This is used for different purposes * 1) missing interrupt handler for normal operation * 2) delayed start of request where start_IO failed with -EBUSY * 3) timeout for missing state change interrupts * The head of the ccw queue will have status DASD_CQR_IN_IO for 1), * DASD_CQR_QUEUED for 2) and 3). */ static void dasd_device_timeout(unsigned long ptr) { unsigned long flags; struct dasd_device *device; device = (struct dasd_device *) ptr; spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); /* re-activate request queue */ dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); dasd_schedule_device_bh(device); } /* * Setup timeout for a device in jiffies. */ void dasd_device_set_timer(struct dasd_device *device, int expires) { if (expires == 0) del_timer(&device->timer); else mod_timer(&device->timer, jiffies + expires); } /* * Clear timeout for a device. */ void dasd_device_clear_timer(struct dasd_device *device) { del_timer(&device->timer); } static void dasd_handle_killed_request(struct ccw_device *cdev, unsigned long intparm) { struct dasd_ccw_req *cqr; struct dasd_device *device; if (!intparm) return; cqr = (struct dasd_ccw_req *) intparm; if (cqr->status != DASD_CQR_IN_IO) { DBF_EVENT_DEVID(DBF_DEBUG, cdev, "invalid status in handle_killed_request: " "%02x", cqr->status); return; } device = dasd_device_from_cdev_locked(cdev); if (IS_ERR(device)) { DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", "unable to get device from cdev"); return; } if (!cqr->startdev || device != cqr->startdev || strncmp(cqr->startdev->discipline->ebcname, (char *) &cqr->magic, 4)) { DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", "invalid device in request"); dasd_put_device(device); return; } /* Schedule request to be retried. */ cqr->status = DASD_CQR_QUEUED; dasd_device_clear_timer(device); dasd_schedule_device_bh(device); dasd_put_device(device); } void dasd_generic_handle_state_change(struct dasd_device *device) { /* First of all start sense subsystem status request. */ dasd_eer_snss(device); dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); dasd_schedule_device_bh(device); if (device->block) dasd_schedule_block_bh(device->block); } /* * Interrupt handler for "normal" ssch-io based dasd devices. */ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) { struct dasd_ccw_req *cqr, *next; struct dasd_device *device; unsigned long long now; int expires; cqr = (struct dasd_ccw_req *) intparm; if (IS_ERR(irb)) { switch (PTR_ERR(irb)) { case -EIO: if (cqr && cqr->status == DASD_CQR_CLEAR_PENDING) { device = (struct dasd_device *) cqr->startdev; cqr->status = DASD_CQR_CLEARED; dasd_device_clear_timer(device); wake_up(&dasd_flush_wq); dasd_schedule_device_bh(device); return; } break; case -ETIMEDOUT: DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " "request timed out\n", __func__); break; default: DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " "unknown error %ld\n", __func__, PTR_ERR(irb)); } dasd_handle_killed_request(cdev, intparm); return; } now = get_tod_clock(); /* check for conditions that should be handled immediately */ if (!cqr || !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && scsw_cstat(&irb->scsw) == 0)) { if (cqr) memcpy(&cqr->irb, irb, sizeof(*irb)); device = dasd_device_from_cdev_locked(cdev); if (IS_ERR(device)) return; /* ignore unsolicited interrupts for DIAG discipline */ if (device->discipline == dasd_diag_discipline_pointer) { dasd_put_device(device); return; } device->discipline->dump_sense_dbf(device, irb, "int"); if (device->features & DASD_FEATURE_ERPLOG) device->discipline->dump_sense(device, cqr, irb); device->discipline->check_for_device_change(device, cqr, irb); dasd_put_device(device); } if (!cqr) return; device = (struct dasd_device *) cqr->startdev; if (!device || strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", "invalid device in request"); return; } /* Check for clear pending */ if (cqr->status == DASD_CQR_CLEAR_PENDING && scsw_fctl(&irb->scsw) & SCSW_FCTL_CLEAR_FUNC) { cqr->status = DASD_CQR_CLEARED; dasd_device_clear_timer(device); wake_up(&dasd_flush_wq); dasd_schedule_device_bh(device); return; } /* check status - the request might have been killed by dyn detach */ if (cqr->status != DASD_CQR_IN_IO) { DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, " "status %02x", dev_name(&cdev->dev), cqr->status); return; } next = NULL; expires = 0; if (scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && scsw_cstat(&irb->scsw) == 0) { /* request was completed successfully */ cqr->status = DASD_CQR_SUCCESS; cqr->stopclk = now; /* Start first request on queue if possible -> fast_io. */ if (cqr->devlist.next != &device->ccw_queue) { next = list_entry(cqr->devlist.next, struct dasd_ccw_req, devlist); } } else { /* error */ /* * If we don't want complex ERP for this request, then just * reset this and retry it in the fastpath */ if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) && cqr->retries > 0) { if (cqr->lpm == device->path_data.opm) DBF_DEV_EVENT(DBF_DEBUG, device, "default ERP in fastpath " "(%i retries left)", cqr->retries); if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) cqr->lpm = device->path_data.opm; cqr->status = DASD_CQR_QUEUED; next = cqr; } else cqr->status = DASD_CQR_ERROR; } if (next && (next->status == DASD_CQR_QUEUED) && (!device->stopped)) { if (device->discipline->start_IO(next) == 0) expires = next->expires; } if (expires != 0) dasd_device_set_timer(device, expires); else dasd_device_clear_timer(device); dasd_schedule_device_bh(device); } enum uc_todo dasd_generic_uc_handler(struct ccw_device *cdev, struct irb *irb) { struct dasd_device *device; device = dasd_device_from_cdev_locked(cdev); if (IS_ERR(device)) goto out; if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || device->state != device->target || !device->discipline->check_for_device_change){ dasd_put_device(device); goto out; } if (device->discipline->dump_sense_dbf) device->discipline->dump_sense_dbf(device, irb, "uc"); device->discipline->check_for_device_change(device, NULL, irb); dasd_put_device(device); out: return UC_TODO_RETRY; } EXPORT_SYMBOL_GPL(dasd_generic_uc_handler); /* * If we have an error on a dasd_block layer request then we cancel * and return all further requests from the same dasd_block as well. */ static void __dasd_device_recovery(struct dasd_device *device, struct dasd_ccw_req *ref_cqr) { struct list_head *l, *n; struct dasd_ccw_req *cqr; /* * only requeue request that came from the dasd_block layer */ if (!ref_cqr->block) return; list_for_each_safe(l, n, &device->ccw_queue) { cqr = list_entry(l, struct dasd_ccw_req, devlist); if (cqr->status == DASD_CQR_QUEUED && ref_cqr->block == cqr->block) { cqr->status = DASD_CQR_CLEARED; } } }; /* * Remove those ccw requests from the queue that need to be returned * to the upper layer. */ static void __dasd_device_process_ccw_queue(struct dasd_device *device, struct list_head *final_queue) { struct list_head *l, *n; struct dasd_ccw_req *cqr; /* Process request with final status. */ list_for_each_safe(l, n, &device->ccw_queue) { cqr = list_entry(l, struct dasd_ccw_req, devlist); /* Stop list processing at the first non-final request. */ if (cqr->status == DASD_CQR_QUEUED || cqr->status == DASD_CQR_IN_IO || cqr->status == DASD_CQR_CLEAR_PENDING) break; if (cqr->status == DASD_CQR_ERROR) { __dasd_device_recovery(device, cqr); } /* Rechain finished requests to final queue */ list_move_tail(&cqr->devlist, final_queue); } } /* * the cqrs from the final queue are returned to the upper layer * by setting a dasd_block state and calling the callback function */ static void __dasd_device_process_final_queue(struct dasd_device *device, struct list_head *final_queue) { struct list_head *l, *n; struct dasd_ccw_req *cqr; struct dasd_block *block; void (*callback)(struct dasd_ccw_req *, void *data); void *callback_data; char errorstring[ERRORLENGTH]; list_for_each_safe(l, n, final_queue) { cqr = list_entry(l, struct dasd_ccw_req, devlist); list_del_init(&cqr->devlist); block = cqr->block; callback = cqr->callback; callback_data = cqr->callback_data; if (block) spin_lock_bh(&block->queue_lock); switch (cqr->status) { case DASD_CQR_SUCCESS: cqr->status = DASD_CQR_DONE; break; case DASD_CQR_ERROR: cqr->status = DASD_CQR_NEED_ERP; break; case DASD_CQR_CLEARED: cqr->status = DASD_CQR_TERMINATED; break; default: /* internal error 12 - wrong cqr status*/ snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status); dev_err(&device->cdev->dev, "An error occurred in the DASD device driver, " "reason=%s\n", errorstring); BUG(); } if (cqr->callback != NULL) (callback)(cqr, callback_data); if (block) spin_unlock_bh(&block->queue_lock); } } /* * Take a look at the first request on the ccw queue and check * if it reached its expire time. If so, terminate the IO. */ static void __dasd_device_check_expire(struct dasd_device *device) { struct dasd_ccw_req *cqr; if (list_empty(&device->ccw_queue)) return; cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) && (time_after_eq(jiffies, cqr->expires + cqr->starttime))) { if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { /* * IO in safe offline processing should not * run out of retries */ cqr->retries++; } if (device->discipline->term_IO(cqr) != 0) { /* Hmpf, try again in 5 sec */ dev_err(&device->cdev->dev, "cqr %p timed out (%lus) but cannot be " "ended, retrying in 5 s\n", cqr, (cqr->expires/HZ)); cqr->expires += 5*HZ; dasd_device_set_timer(device, 5*HZ); } else { dev_err(&device->cdev->dev, "cqr %p timed out (%lus), %i retries " "remaining\n", cqr, (cqr->expires/HZ), cqr->retries); } } } /* * return 1 when device is not eligible for IO */ static int __dasd_device_is_unusable(struct dasd_device *device, struct dasd_ccw_req *cqr) { int mask = ~(DASD_STOPPED_DC_WAIT | DASD_UNRESUMED_PM); if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { /* dasd is being set offline. */ return 1; } if (device->stopped) { if (device->stopped & mask) { /* stopped and CQR will not change that. */ return 1; } if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { /* CQR is not able to change device to * operational. */ return 1; } /* CQR required to get device operational. */ } return 0; } /* * Take a look at the first request on the ccw queue and check * if it needs to be started. */ static void __dasd_device_start_head(struct dasd_device *device) { struct dasd_ccw_req *cqr; int rc; if (list_empty(&device->ccw_queue)) return; cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); if (cqr->status != DASD_CQR_QUEUED) return; /* if device is not usable return request to upper layer */ if (__dasd_device_is_unusable(device, cqr)) { cqr->intrc = -EAGAIN; cqr->status = DASD_CQR_CLEARED; dasd_schedule_device_bh(device); return; } rc = device->discipline->start_IO(cqr); if (rc == 0) dasd_device_set_timer(device, cqr->expires); else if (rc == -EACCES) { dasd_schedule_device_bh(device); } else /* Hmpf, try again in 1/2 sec */ dasd_device_set_timer(device, 50); } static void __dasd_device_check_path_events(struct dasd_device *device) { int rc; if (device->path_data.tbvpm) { if (device->stopped & ~(DASD_STOPPED_DC_WAIT | DASD_UNRESUMED_PM)) return; rc = device->discipline->verify_path( device, device->path_data.tbvpm); if (rc) dasd_device_set_timer(device, 50); else device->path_data.tbvpm = 0; } }; /* * Go through all request on the dasd_device request queue, * terminate them on the cdev if necessary, and return them to the * submitting layer via callback. * Note: * Make sure that all 'submitting layers' still exist when * this function is called!. In other words, when 'device' is a base * device then all block layer requests must have been removed before * via dasd_flush_block_queue. */ int dasd_flush_device_queue(struct dasd_device *device) { struct dasd_ccw_req *cqr, *n; int rc; struct list_head flush_queue; INIT_LIST_HEAD(&flush_queue); spin_lock_irq(get_ccwdev_lock(device->cdev)); rc = 0; list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { /* Check status and move request to flush_queue */ switch (cqr->status) { case DASD_CQR_IN_IO: rc = device->discipline->term_IO(cqr); if (rc) { /* unable to terminate requeust */ dev_err(&device->cdev->dev, "Flushing the DASD request queue " "failed for request %p\n", cqr); /* stop flush processing */ goto finished; } break; case DASD_CQR_QUEUED: cqr->stopclk = get_tod_clock(); cqr->status = DASD_CQR_CLEARED; break; default: /* no need to modify the others */ break; } list_move_tail(&cqr->devlist, &flush_queue); } finished: spin_unlock_irq(get_ccwdev_lock(device->cdev)); /* * After this point all requests must be in state CLEAR_PENDING, * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become * one of the others. */ list_for_each_entry_safe(cqr, n, &flush_queue, devlist) wait_event(dasd_flush_wq, (cqr->status != DASD_CQR_CLEAR_PENDING)); /* * Now set each request back to TERMINATED, DONE or NEED_ERP * and call the callback function of flushed requests */ __dasd_device_process_final_queue(device, &flush_queue); return rc; } /* * Acquire the device lock and process queues for the device. */ static void dasd_device_tasklet(struct dasd_device *device) { struct list_head final_queue; atomic_set (&device->tasklet_scheduled, 0); INIT_LIST_HEAD(&final_queue); spin_lock_irq(get_ccwdev_lock(device->cdev)); /* Check expire time of first request on the ccw queue. */ __dasd_device_check_expire(device); /* find final requests on ccw queue */ __dasd_device_process_ccw_queue(device, &final_queue); __dasd_device_check_path_events(device); spin_unlock_irq(get_ccwdev_lock(device->cdev)); /* Now call the callback function of requests with final status */ __dasd_device_process_final_queue(device, &final_queue); spin_lock_irq(get_ccwdev_lock(device->cdev)); /* Now check if the head of the ccw queue needs to be started. */ __dasd_device_start_head(device); spin_unlock_irq(get_ccwdev_lock(device->cdev)); if (waitqueue_active(&shutdown_waitq)) wake_up(&shutdown_waitq); dasd_put_device(device); } /* * Schedules a call to dasd_tasklet over the device tasklet. */ void dasd_schedule_device_bh(struct dasd_device *device) { /* Protect against rescheduling. */ if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) return; dasd_get_device(device); tasklet_hi_schedule(&device->tasklet); } void dasd_device_set_stop_bits(struct dasd_device *device, int bits) { device->stopped |= bits; } EXPORT_SYMBOL_GPL(dasd_device_set_stop_bits); void dasd_device_remove_stop_bits(struct dasd_device *device, int bits) { device->stopped &= ~bits; if (!device->stopped) wake_up(&generic_waitq); } EXPORT_SYMBOL_GPL(dasd_device_remove_stop_bits); /* * Queue a request to the head of the device ccw_queue. * Start the I/O if possible. */ void dasd_add_request_head(struct dasd_ccw_req *cqr) { struct dasd_device *device; unsigned long flags; device = cqr->startdev; spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); cqr->status = DASD_CQR_QUEUED; list_add(&cqr->devlist, &device->ccw_queue); /* let the bh start the request to keep them in order */ dasd_schedule_device_bh(device); spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); } /* * Queue a request to the tail of the device ccw_queue. * Start the I/O if possible. */ void dasd_add_request_tail(struct dasd_ccw_req *cqr) { struct dasd_device *device; unsigned long flags; device = cqr->startdev; spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); cqr->status = DASD_CQR_QUEUED; list_add_tail(&cqr->devlist, &device->ccw_queue); /* let the bh start the request to keep them in order */ dasd_schedule_device_bh(device); spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); } /* * Wakeup helper for the 'sleep_on' functions. */ void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data) { spin_lock_irq(get_ccwdev_lock(cqr->startdev->cdev)); cqr->callback_data = DASD_SLEEPON_END_TAG; spin_unlock_irq(get_ccwdev_lock(cqr->startdev->cdev)); wake_up(&generic_waitq); } EXPORT_SYMBOL_GPL(dasd_wakeup_cb); static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr) { struct dasd_device *device; int rc; device = cqr->startdev; spin_lock_irq(get_ccwdev_lock(device->cdev)); rc = (cqr->callback_data == DASD_SLEEPON_END_TAG); spin_unlock_irq(get_ccwdev_lock(device->cdev)); return rc; } /* * checks if error recovery is necessary, returns 1 if yes, 0 otherwise. */ static int __dasd_sleep_on_erp(struct dasd_ccw_req *cqr) { struct dasd_device *device; dasd_erp_fn_t erp_fn; if (cqr->status == DASD_CQR_FILLED) return 0; device = cqr->startdev; if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { if (cqr->status == DASD_CQR_TERMINATED) { device->discipline->handle_terminated_request(cqr); return 1; } if (cqr->status == DASD_CQR_NEED_ERP) { erp_fn = device->discipline->erp_action(cqr); erp_fn(cqr); return 1; } if (cqr->status == DASD_CQR_FAILED) dasd_log_sense(cqr, &cqr->irb); if (cqr->refers) { __dasd_process_erp(device, cqr); return 1; } } return 0; } static int __dasd_sleep_on_loop_condition(struct dasd_ccw_req *cqr) { if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { if (cqr->refers) /* erp is not done yet */ return 1; return ((cqr->status != DASD_CQR_DONE) && (cqr->status != DASD_CQR_FAILED)); } else return (cqr->status == DASD_CQR_FILLED); } static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible) { struct dasd_device *device; int rc; struct list_head ccw_queue; struct dasd_ccw_req *cqr; INIT_LIST_HEAD(&ccw_queue); maincqr->status = DASD_CQR_FILLED; device = maincqr->startdev; list_add(&maincqr->blocklist, &ccw_queue); for (cqr = maincqr; __dasd_sleep_on_loop_condition(cqr); cqr = list_first_entry(&ccw_queue, struct dasd_ccw_req, blocklist)) { if (__dasd_sleep_on_erp(cqr)) continue; if (cqr->status != DASD_CQR_FILLED) /* could be failed */ continue; if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EPERM; continue; } /* Non-temporary stop condition will trigger fail fast */ if (device->stopped & ~DASD_STOPPED_PENDING && test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && (!dasd_eer_enabled(device))) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EAGAIN; continue; } /* * Don't try to start requests if device is stopped * except path verification requests */ if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { if (interruptible) { rc = wait_event_interruptible( generic_waitq, !(device->stopped)); if (rc == -ERESTARTSYS) { cqr->status = DASD_CQR_FAILED; maincqr->intrc = rc; continue; } } else wait_event(generic_waitq, !(device->stopped)); } if (!cqr->callback) cqr->callback = dasd_wakeup_cb; cqr->callback_data = DASD_SLEEPON_START_TAG; dasd_add_request_tail(cqr); if (interruptible) { rc = wait_event_interruptible( generic_waitq, _wait_for_wakeup(cqr)); if (rc == -ERESTARTSYS) { dasd_cancel_req(cqr); /* wait (non-interruptible) for final status */ wait_event(generic_waitq, _wait_for_wakeup(cqr)); cqr->status = DASD_CQR_FAILED; maincqr->intrc = rc; continue; } } else wait_event(generic_waitq, _wait_for_wakeup(cqr)); } maincqr->endclk = get_tod_clock(); if ((maincqr->status != DASD_CQR_DONE) && (maincqr->intrc != -ERESTARTSYS)) dasd_log_sense(maincqr, &maincqr->irb); if (maincqr->status == DASD_CQR_DONE) rc = 0; else if (maincqr->intrc) rc = maincqr->intrc; else rc = -EIO; return rc; } static inline int _wait_for_wakeup_queue(struct list_head *ccw_queue) { struct dasd_ccw_req *cqr; list_for_each_entry(cqr, ccw_queue, blocklist) { if (cqr->callback_data != DASD_SLEEPON_END_TAG) return 0; } return 1; } static int _dasd_sleep_on_queue(struct list_head *ccw_queue, int interruptible) { struct dasd_device *device; struct dasd_ccw_req *cqr, *n; int rc; retry: list_for_each_entry_safe(cqr, n, ccw_queue, blocklist) { device = cqr->startdev; if (cqr->status != DASD_CQR_FILLED) /*could be failed*/ continue; if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EPERM; continue; } /*Non-temporary stop condition will trigger fail fast*/ if (device->stopped & ~DASD_STOPPED_PENDING && test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && !dasd_eer_enabled(device)) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EAGAIN; continue; } /*Don't try to start requests if device is stopped*/ if (interruptible) { rc = wait_event_interruptible( generic_waitq, !device->stopped); if (rc == -ERESTARTSYS) { cqr->status = DASD_CQR_FAILED; cqr->intrc = rc; continue; } } else wait_event(generic_waitq, !(device->stopped)); if (!cqr->callback) cqr->callback = dasd_wakeup_cb; cqr->callback_data = DASD_SLEEPON_START_TAG; dasd_add_request_tail(cqr); } wait_event(generic_waitq, _wait_for_wakeup_queue(ccw_queue)); rc = 0; list_for_each_entry_safe(cqr, n, ccw_queue, blocklist) { /* * for alias devices simplify error recovery and * return to upper layer * do not skip ERP requests */ if (cqr->startdev != cqr->basedev && !cqr->refers && (cqr->status == DASD_CQR_TERMINATED || cqr->status == DASD_CQR_NEED_ERP)) return -EAGAIN; /* normal recovery for basedev IO */ if (__dasd_sleep_on_erp(cqr)) /* handle erp first */ goto retry; } return 0; } /* * Queue a request to the tail of the device ccw_queue and wait for * it's completion. */ int dasd_sleep_on(struct dasd_ccw_req *cqr) { return _dasd_sleep_on(cqr, 0); } /* * Start requests from a ccw_queue and wait for their completion. */ int dasd_sleep_on_queue(struct list_head *ccw_queue) { return _dasd_sleep_on_queue(ccw_queue, 0); } EXPORT_SYMBOL(dasd_sleep_on_queue); /* * Queue a request to the tail of the device ccw_queue and wait * interruptible for it's completion. */ int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr) { return _dasd_sleep_on(cqr, 1); } /* * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock * for eckd devices) the currently running request has to be terminated * and be put back to status queued, before the special request is added * to the head of the queue. Then the special request is waited on normally. */ static inline int _dasd_term_running_cqr(struct dasd_device *device) { struct dasd_ccw_req *cqr; int rc; if (list_empty(&device->ccw_queue)) return 0; cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); rc = device->discipline->term_IO(cqr); if (!rc) /* * CQR terminated because a more important request is pending. * Undo decreasing of retry counter because this is * not an error case. */ cqr->retries++; return rc; } int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) { struct dasd_device *device; int rc; device = cqr->startdev; if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EPERM; return -EIO; } spin_lock_irq(get_ccwdev_lock(device->cdev)); rc = _dasd_term_running_cqr(device); if (rc) { spin_unlock_irq(get_ccwdev_lock(device->cdev)); return rc; } cqr->callback = dasd_wakeup_cb; cqr->callback_data = DASD_SLEEPON_START_TAG; cqr->status = DASD_CQR_QUEUED; /* * add new request as second * first the terminated cqr needs to be finished */ list_add(&cqr->devlist, device->ccw_queue.next); /* let the bh start the request to keep them in order */ dasd_schedule_device_bh(device); spin_unlock_irq(get_ccwdev_lock(device->cdev)); wait_event(generic_waitq, _wait_for_wakeup(cqr)); if (cqr->status == DASD_CQR_DONE) rc = 0; else if (cqr->intrc) rc = cqr->intrc; else rc = -EIO; /* kick tasklets */ dasd_schedule_device_bh(device); if (device->block) dasd_schedule_block_bh(device->block); return rc; } /* * Cancels a request that was started with dasd_sleep_on_req. * This is useful to timeout requests. The request will be * terminated if it is currently in i/o. * Returns 1 if the request has been terminated. * 0 if there was no need to terminate the request (not started yet) * negative error code if termination failed * Cancellation of a request is an asynchronous operation! The calling * function has to wait until the request is properly returned via callback. */ int dasd_cancel_req(struct dasd_ccw_req *cqr) { struct dasd_device *device = cqr->startdev; unsigned long flags; int rc; rc = 0; spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); switch (cqr->status) { case DASD_CQR_QUEUED: /* request was not started - just set to cleared */ cqr->status = DASD_CQR_CLEARED; if (cqr->callback_data == DASD_SLEEPON_START_TAG) cqr->callback_data = DASD_SLEEPON_END_TAG; break; case DASD_CQR_IN_IO: /* request in IO - terminate IO and release again */ rc = device->discipline->term_IO(cqr); if (rc) { dev_err(&device->cdev->dev, "Cancelling request %p failed with rc=%d\n", cqr, rc); } else { cqr->stopclk = get_tod_clock(); } break; default: /* already finished or clear pending - do nothing */ break; } spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); dasd_schedule_device_bh(device); return rc; } /* * SECTION: Operations of the dasd_block layer. */ /* * Timeout function for dasd_block. This is used when the block layer * is waiting for something that may not come reliably, (e.g. a state * change interrupt) */ static void dasd_block_timeout(unsigned long ptr) { unsigned long flags; struct dasd_block *block; block = (struct dasd_block *) ptr; spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags); /* re-activate request queue */ dasd_device_remove_stop_bits(block->base, DASD_STOPPED_PENDING); spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags); dasd_schedule_block_bh(block); } /* * Setup timeout for a dasd_block in jiffies. */ void dasd_block_set_timer(struct dasd_block *block, int expires) { if (expires == 0) del_timer(&block->timer); else mod_timer(&block->timer, jiffies + expires); } /* * Clear timeout for a dasd_block. */ void dasd_block_clear_timer(struct dasd_block *block) { del_timer(&block->timer); } /* * Process finished error recovery ccw. */ static void __dasd_process_erp(struct dasd_device *device, struct dasd_ccw_req *cqr) { dasd_erp_fn_t erp_fn; if (cqr->status == DASD_CQR_DONE) DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful"); else dev_err(&device->cdev->dev, "ERP failed for the DASD\n"); erp_fn = device->discipline->erp_postaction(cqr); erp_fn(cqr); } /* * Fetch requests from the block device queue. */ static void __dasd_process_request_queue(struct dasd_block *block) { struct request_queue *queue; struct request *req; struct dasd_ccw_req *cqr; struct dasd_device *basedev; unsigned long flags; queue = block->request_queue; basedev = block->base; /* No queue ? Then there is nothing to do. */ if (queue == NULL) return; /* * We requeue request from the block device queue to the ccw * queue only in two states. In state DASD_STATE_READY the * partition detection is done and we need to requeue requests * for that. State DASD_STATE_ONLINE is normal block device * operation. */ if (basedev->state < DASD_STATE_READY) { while ((req = blk_fetch_request(block->request_queue))) __blk_end_request_all(req, -EIO); return; } /* * if device is stopped do not fetch new requests * except failfast is active which will let requests fail * immediately in __dasd_block_start_head() */ if (basedev->stopped && !(basedev->features & DASD_FEATURE_FAILFAST)) return; /* Now we try to fetch requests from the request queue */ while ((req = blk_peek_request(queue))) { if (basedev->features & DASD_FEATURE_READONLY && rq_data_dir(req) == WRITE) { DBF_DEV_EVENT(DBF_ERR, basedev, "Rejecting write request %p", req); blk_start_request(req); __blk_end_request_all(req, -EIO); continue; } cqr = basedev->discipline->build_cp(basedev, block, req); if (IS_ERR(cqr)) { if (PTR_ERR(cqr) == -EBUSY) break; /* normal end condition */ if (PTR_ERR(cqr) == -ENOMEM) break; /* terminate request queue loop */ if (PTR_ERR(cqr) == -EAGAIN) { /* * The current request cannot be build right * now, we have to try later. If this request * is the head-of-queue we stop the device * for 1/2 second. */ if (!list_empty(&block->ccw_queue)) break; spin_lock_irqsave( get_ccwdev_lock(basedev->cdev), flags); dasd_device_set_stop_bits(basedev, DASD_STOPPED_PENDING); spin_unlock_irqrestore( get_ccwdev_lock(basedev->cdev), flags); dasd_block_set_timer(block, HZ/2); break; } DBF_DEV_EVENT(DBF_ERR, basedev, "CCW creation failed (rc=%ld) " "on request %p", PTR_ERR(cqr), req); blk_start_request(req); __blk_end_request_all(req, -EIO); continue; } /* * Note: callback is set to dasd_return_cqr_cb in * __dasd_block_start_head to cover erp requests as well */ cqr->callback_data = (void *) req; cqr->status = DASD_CQR_FILLED; blk_start_request(req); list_add_tail(&cqr->blocklist, &block->ccw_queue); dasd_profile_start(block, cqr, req); } } static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr) { struct request *req; int status; int error = 0; req = (struct request *) cqr->callback_data; dasd_profile_end(cqr->block, cqr, req); status = cqr->block->base->discipline->free_cp(cqr, req); if (status <= 0) error = status ? status : -EIO; __blk_end_request_all(req, error); } /* * Process ccw request queue. */ static void __dasd_process_block_ccw_queue(struct dasd_block *block, struct list_head *final_queue) { struct list_head *l, *n; struct dasd_ccw_req *cqr; dasd_erp_fn_t erp_fn; unsigned long flags; struct dasd_device *base = block->base; restart: /* Process request with final status. */ list_for_each_safe(l, n, &block->ccw_queue) { cqr = list_entry(l, struct dasd_ccw_req, blocklist); if (cqr->status != DASD_CQR_DONE && cqr->status != DASD_CQR_FAILED && cqr->status != DASD_CQR_NEED_ERP && cqr->status != DASD_CQR_TERMINATED) continue; if (cqr->status == DASD_CQR_TERMINATED) { base->discipline->handle_terminated_request(cqr); goto restart; } /* Process requests that may be recovered */ if (cqr->status == DASD_CQR_NEED_ERP) { erp_fn = base->discipline->erp_action(cqr); if (IS_ERR(erp_fn(cqr))) continue; goto restart; } /* log sense for fatal error */ if (cqr->status == DASD_CQR_FAILED) { dasd_log_sense(cqr, &cqr->irb); } /* First of all call extended error reporting. */ if (dasd_eer_enabled(base) && cqr->status == DASD_CQR_FAILED) { dasd_eer_write(base, cqr, DASD_EER_FATALERROR); /* restart request */ cqr->status = DASD_CQR_FILLED; cqr->retries = 255; spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); dasd_device_set_stop_bits(base, DASD_STOPPED_QUIESCE); spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), flags); goto restart; } /* Process finished ERP request. */ if (cqr->refers) { __dasd_process_erp(base, cqr); goto restart; } /* Rechain finished requests to final queue */ cqr->endclk = get_tod_clock(); list_move_tail(&cqr->blocklist, final_queue); } } static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data) { dasd_schedule_block_bh(cqr->block); } static void __dasd_block_start_head(struct dasd_block *block) { struct dasd_ccw_req *cqr; if (list_empty(&block->ccw_queue)) return; /* We allways begin with the first requests on the queue, as some * of previously started requests have to be enqueued on a * dasd_device again for error recovery. */ list_for_each_entry(cqr, &block->ccw_queue, blocklist) { if (cqr->status != DASD_CQR_FILLED) continue; if (test_bit(DASD_FLAG_LOCK_STOLEN, &block->base->flags) && !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { cqr->status = DASD_CQR_FAILED; cqr->intrc = -EPERM; dasd_schedule_block_bh(block); continue; } /* Non-temporary stop condition will trigger fail fast */ if (block->base->stopped & ~DASD_STOPPED_PENDING && test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && (!dasd_eer_enabled(block->base))) { cqr->status = DASD_CQR_FAILED; dasd_schedule_block_bh(block); continue; } /* Don't try to start requests if device is stopped */ if (block->base->stopped) return; /* just a fail safe check, should not happen */ if (!cqr->startdev) cqr->startdev = block->base; /* make sure that the requests we submit find their way back */ cqr->callback = dasd_return_cqr_cb; dasd_add_request_tail(cqr); } } /* * Central dasd_block layer routine. Takes requests from the generic * block layer request queue, creates ccw requests, enqueues them on * a dasd_device and processes ccw requests that have been returned. */ static void dasd_block_tasklet(struct dasd_block *block) { struct list_head final_queue; struct list_head *l, *n; struct dasd_ccw_req *cqr; atomic_set(&block->tasklet_scheduled, 0); INIT_LIST_HEAD(&final_queue); spin_lock(&block->queue_lock); /* Finish off requests on ccw queue */ __dasd_process_block_ccw_queue(block, &final_queue); spin_unlock(&block->queue_lock); /* Now call the callback function of requests with final status */ spin_lock_irq(&block->request_queue_lock); list_for_each_safe(l, n, &final_queue) { cqr = list_entry(l, struct dasd_ccw_req, blocklist); list_del_init(&cqr->blocklist); __dasd_cleanup_cqr(cqr); } spin_lock(&block->queue_lock); /* Get new request from the block device request queue */ __dasd_process_request_queue(block); /* Now check if the head of the ccw queue needs to be started. */ __dasd_block_start_head(block); spin_unlock(&block->queue_lock); spin_unlock_irq(&block->request_queue_lock); if (waitqueue_active(&shutdown_waitq)) wake_up(&shutdown_waitq); dasd_put_device(block->base); } static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data) { wake_up(&dasd_flush_wq); } /* * Requeue a request back to the block request queue * only works for block requests */ static int _dasd_requeue_request(struct dasd_ccw_req *cqr) { struct dasd_block *block = cqr->block; struct request *req; unsigned long flags; if (!block) return -EINVAL; spin_lock_irqsave(&block->queue_lock, flags); req = (struct request *) cqr->callback_data; blk_requeue_request(block->request_queue, req); spin_unlock_irqrestore(&block->queue_lock, flags); return 0; } /* * Go through all request on the dasd_block request queue, cancel them * on the respective dasd_device, and return them to the generic * block layer. */ static int dasd_flush_block_queue(struct dasd_block *block) { struct dasd_ccw_req *cqr, *n; int rc, i; struct list_head flush_queue; INIT_LIST_HEAD(&flush_queue); spin_lock_bh(&block->queue_lock); rc = 0; restart: list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) { /* if this request currently owned by a dasd_device cancel it */ if (cqr->status >= DASD_CQR_QUEUED) rc = dasd_cancel_req(cqr); if (rc < 0) break; /* Rechain request (including erp chain) so it won't be * touched by the dasd_block_tasklet anymore. * Replace the callback so we notice when the request * is returned from the dasd_device layer. */ cqr->callback = _dasd_wake_block_flush_cb; for (i = 0; cqr != NULL; cqr = cqr->refers, i++) list_move_tail(&cqr->blocklist, &flush_queue); if (i > 1) /* moved more than one request - need to restart */ goto restart; } spin_unlock_bh(&block->queue_lock); /* Now call the callback function of flushed requests */ restart_cb: list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) { wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED)); /* Process finished ERP request. */ if (cqr->refers) { spin_lock_bh(&block->queue_lock); __dasd_process_erp(block->base, cqr); spin_unlock_bh(&block->queue_lock); /* restart list_for_xx loop since dasd_process_erp * might remove multiple elements */ goto restart_cb; } /* call the callback function */ spin_lock_irq(&block->request_queue_lock); cqr->endclk = get_tod_clock(); list_del_init(&cqr->blocklist); __dasd_cleanup_cqr(cqr); spin_unlock_irq(&block->request_queue_lock); } return rc; } /* * Schedules a call to dasd_tasklet over the device tasklet. */ void dasd_schedule_block_bh(struct dasd_block *block) { /* Protect against rescheduling. */ if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0) return; /* life cycle of block is bound to it's base device */ dasd_get_device(block->base); tasklet_hi_schedule(&block->tasklet); } /* * SECTION: external block device operations * (request queue handling, open, release, etc.) */ /* * Dasd request queue function. Called from ll_rw_blk.c */ static void do_dasd_request(struct request_queue *queue) { struct dasd_block *block; block = queue->queuedata; spin_lock(&block->queue_lock); /* Get new request from the block device request queue */ __dasd_process_request_queue(block); /* Now check if the head of the ccw queue needs to be started. */ __dasd_block_start_head(block); spin_unlock(&block->queue_lock); } /* * Allocate and initialize request queue and default I/O scheduler. */ static int dasd_alloc_queue(struct dasd_block *block) { int rc; block->request_queue = blk_init_queue(do_dasd_request, &block->request_queue_lock); if (block->request_queue == NULL) return -ENOMEM; block->request_queue->queuedata = block; elevator_exit(block->request_queue->elevator); block->request_queue->elevator = NULL; mutex_lock(&block->request_queue->sysfs_lock); rc = elevator_init(block->request_queue, "deadline"); if (rc) blk_cleanup_queue(block->request_queue); mutex_unlock(&block->request_queue->sysfs_lock); return rc; } /* * Allocate and initialize request queue. */ static void dasd_setup_queue(struct dasd_block *block) { int max; if (block->base->features & DASD_FEATURE_USERAW) { /* * the max_blocks value for raw_track access is 256 * it is higher than the native ECKD value because we * only need one ccw per track * so the max_hw_sectors are * 2048 x 512B = 1024kB = 16 tracks */ max = 2048; } else { max = block->base->discipline->max_blocks << block->s2b_shift; } blk_queue_logical_block_size(block->request_queue, block->bp_block); blk_queue_max_hw_sectors(block->request_queue, max); blk_queue_max_segments(block->request_queue, -1L); /* with page sized segments we can translate each segement into * one idaw/tidaw */ blk_queue_max_segment_size(block->request_queue, PAGE_SIZE); blk_queue_segment_boundary(block->request_queue, PAGE_SIZE - 1); } /* * Deactivate and free request queue. */ static void dasd_free_queue(struct dasd_block *block) { if (block->request_queue) { blk_cleanup_queue(block->request_queue); block->request_queue = NULL; } } /* * Flush request on the request queue. */ static void dasd_flush_request_queue(struct dasd_block *block) { struct request *req; if (!block->request_queue) return; spin_lock_irq(&block->request_queue_lock); while ((req = blk_fetch_request(block->request_queue))) __blk_end_request_all(req, -EIO); spin_unlock_irq(&block->request_queue_lock); } static int dasd_open(struct block_device *bdev, fmode_t mode) { struct dasd_device *base; int rc; base = dasd_device_from_gendisk(bdev->bd_disk); if (!base) return -ENODEV; atomic_inc(&base->block->open_count); if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) { rc = -ENODEV; goto unlock; } if (!try_module_get(base->discipline->owner)) { rc = -EINVAL; goto unlock; } if (dasd_probeonly) { dev_info(&base->cdev->dev, "Accessing the DASD failed because it is in " "probeonly mode\n"); rc = -EPERM; goto out; } if (base->state <= DASD_STATE_BASIC) { DBF_DEV_EVENT(DBF_ERR, base, " %s", " Cannot open unrecognized device"); rc = -ENODEV; goto out; } if ((mode & FMODE_WRITE) && (test_bit(DASD_FLAG_DEVICE_RO, &base->flags) || (base->features & DASD_FEATURE_READONLY))) { rc = -EROFS; goto out; } dasd_put_device(base); return 0; out: module_put(base->discipline->owner); unlock: atomic_dec(&base->block->open_count); dasd_put_device(base); return rc; } static void dasd_release(struct gendisk *disk, fmode_t mode) { struct dasd_device *base = dasd_device_from_gendisk(disk); if (base) { atomic_dec(&base->block->open_count); module_put(base->discipline->owner); dasd_put_device(base); } } /* * Return disk geometry. */ static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) { struct dasd_device *base; base = dasd_device_from_gendisk(bdev->bd_disk); if (!base) return -ENODEV; if (!base->discipline || !base->discipline->fill_geometry) { dasd_put_device(base); return -EINVAL; } base->discipline->fill_geometry(base->block, geo); geo->start = get_start_sect(bdev) >> base->block->s2b_shift; dasd_put_device(base); return 0; } const struct block_device_operations dasd_device_operations = { .owner = THIS_MODULE, .open = dasd_open, .release = dasd_release, .ioctl = dasd_ioctl, .compat_ioctl = dasd_ioctl, .getgeo = dasd_getgeo, }; /******************************************************************************* * end of block device operations */ static void dasd_exit(void) { #ifdef CONFIG_PROC_FS dasd_proc_exit(); #endif dasd_eer_exit(); if (dasd_page_cache != NULL) { kmem_cache_destroy(dasd_page_cache); dasd_page_cache = NULL; } dasd_gendisk_exit(); dasd_devmap_exit(); if (dasd_debug_area != NULL) { debug_unregister(dasd_debug_area); dasd_debug_area = NULL; } dasd_statistics_removeroot(); } /* * SECTION: common functions for ccw_driver use */ /* * Is the device read-only? * Note that this function does not report the setting of the * readonly device attribute, but how it is configured in z/VM. */ int dasd_device_is_ro(struct dasd_device *device) { struct ccw_dev_id dev_id; struct diag210 diag_data; int rc; if (!MACHINE_IS_VM) return 0; ccw_device_get_id(device->cdev, &dev_id); memset(&diag_data, 0, sizeof(diag_data)); diag_data.vrdcdvno = dev_id.devno; diag_data.vrdclen = sizeof(diag_data); rc = diag210(&diag_data); if (rc == 0 || rc == 2) { return diag_data.vrdcvfla & 0x80; } else { DBF_EVENT(DBF_WARNING, "diag210 failed for dev=%04x with rc=%d", dev_id.devno, rc); return 0; } } EXPORT_SYMBOL_GPL(dasd_device_is_ro); static void dasd_generic_auto_online(void *data, async_cookie_t cookie) { struct ccw_device *cdev = data; int ret; ret = ccw_device_set_online(cdev); if (ret) pr_warning("%s: Setting the DASD online failed with rc=%d\n", dev_name(&cdev->dev), ret); } /* * Initial attempt at a probe function. this can be simplified once * the other detection code is gone. */ int dasd_generic_probe(struct ccw_device *cdev, struct dasd_discipline *discipline) { int ret; ret = dasd_add_sysfs_files(cdev); if (ret) { DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s", "dasd_generic_probe: could not add " "sysfs entries"); return ret; } cdev->handler = &dasd_int_handler; /* * Automatically online either all dasd devices (dasd_autodetect) * or all devices specified with dasd= parameters during * initial probe. */ if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) || (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0)) async_schedule(dasd_generic_auto_online, cdev); return 0; } /* * This will one day be called from a global not_oper handler. * It is also used by driver_unregister during module unload. */ void dasd_generic_remove(struct ccw_device *cdev) { struct dasd_device *device; struct dasd_block *block; cdev->handler = NULL; device = dasd_device_from_cdev(cdev); if (IS_ERR(device)) { dasd_remove_sysfs_files(cdev); return; } if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags) && !test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { /* Already doing offline processing */ dasd_put_device(device); dasd_remove_sysfs_files(cdev); return; } /* * This device is removed unconditionally. Set offline * flag to prevent dasd_open from opening it while it is * no quite down yet. */ dasd_set_target_state(device, DASD_STATE_NEW); /* dasd_delete_device destroys the device reference. */ block = device->block; dasd_delete_device(device); /* * life cycle of block is bound to device, so delete it after * device was safely removed */ if (block) dasd_free_block(block); dasd_remove_sysfs_files(cdev); } /* * Activate a device. This is called from dasd_{eckd,fba}_probe() when either * the device is detected for the first time and is supposed to be used * or the user has started activation through sysfs. */ int dasd_generic_set_online(struct ccw_device *cdev, struct dasd_discipline *base_discipline) { struct dasd_discipline *discipline; struct dasd_device *device; int rc; /* first online clears initial online feature flag */ dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0); device = dasd_create_device(cdev); if (IS_ERR(device)) return PTR_ERR(device); discipline = base_discipline; if (device->features & DASD_FEATURE_USEDIAG) { if (!dasd_diag_discipline_pointer) { pr_warning("%s Setting the DASD online failed because " "of missing DIAG discipline\n", dev_name(&cdev->dev)); dasd_delete_device(device); return -ENODEV; } discipline = dasd_diag_discipline_pointer; } if (!try_module_get(base_discipline->owner)) { dasd_delete_device(device); return -EINVAL; } if (!try_module_get(discipline->owner)) { module_put(base_discipline->owner); dasd_delete_device(device); return -EINVAL; } device->base_discipline = base_discipline; device->discipline = discipline; /* check_device will allocate block device if necessary */ rc = discipline->check_device(device); if (rc) { pr_warning("%s Setting the DASD online with discipline %s " "failed with rc=%i\n", dev_name(&cdev->dev), discipline->name, rc); module_put(discipline->owner); module_put(base_discipline->owner); dasd_delete_device(device); return rc; } dasd_set_target_state(device, DASD_STATE_ONLINE); if (device->state <= DASD_STATE_KNOWN) { pr_warning("%s Setting the DASD online failed because of a " "missing discipline\n", dev_name(&cdev->dev)); rc = -ENODEV; dasd_set_target_state(device, DASD_STATE_NEW); if (device->block) dasd_free_block(device->block); dasd_delete_device(device); } else pr_debug("dasd_generic device %s found\n", dev_name(&cdev->dev)); wait_event(dasd_init_waitq, _wait_for_device(device)); dasd_put_device(device); return rc; } int dasd_generic_set_offline(struct ccw_device *cdev) { struct dasd_device *device; struct dasd_block *block; int max_count, open_count, rc; rc = 0; device = dasd_device_from_cdev(cdev); if (IS_ERR(device)) return PTR_ERR(device); /* * We must make sure that this device is currently not in use. * The open_count is increased for every opener, that includes * the blkdev_get in dasd_scan_partitions. We are only interested * in the other openers. */ if (device->block) { max_count = device->block->bdev ? 0 : -1; open_count = atomic_read(&device->block->open_count); if (open_count > max_count) { if (open_count > 0) pr_warning("%s: The DASD cannot be set offline " "with open count %i\n", dev_name(&cdev->dev), open_count); else pr_warning("%s: The DASD cannot be set offline " "while it is in use\n", dev_name(&cdev->dev)); clear_bit(DASD_FLAG_OFFLINE, &device->flags); dasd_put_device(device); return -EBUSY; } } if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { /* * safe offline allready running * could only be called by normal offline so safe_offline flag * needs to be removed to run normal offline and kill all I/O */ if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) { /* Already doing normal offline processing */ dasd_put_device(device); return -EBUSY; } else clear_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags); } else if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { /* Already doing offline processing */ dasd_put_device(device); return -EBUSY; } /* * if safe_offline called set safe_offline_running flag and * clear safe_offline so that a call to normal offline * can overrun safe_offline processing */ if (test_and_clear_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags) && !test_and_set_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { /* * If we want to set the device safe offline all IO operations * should be finished before continuing the offline process * so sync bdev first and then wait for our queues to become * empty */ /* sync blockdev and partitions */ rc = fsync_bdev(device->block->bdev); if (rc != 0) goto interrupted; /* schedule device tasklet and wait for completion */ dasd_schedule_device_bh(device); rc = wait_event_interruptible(shutdown_waitq, _wait_for_empty_queues(device)); if (rc != 0) goto interrupted; } set_bit(DASD_FLAG_OFFLINE, &device->flags); dasd_set_target_state(device, DASD_STATE_NEW); /* dasd_delete_device destroys the device reference. */ block = device->block; dasd_delete_device(device); /* * life cycle of block is bound to device, so delete it after * device was safely removed */ if (block) dasd_free_block(block); return 0; interrupted: /* interrupted by signal */ clear_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags); clear_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags); clear_bit(DASD_FLAG_OFFLINE, &device->flags); dasd_put_device(device); return rc; } int dasd_generic_last_path_gone(struct dasd_device *device) { struct dasd_ccw_req *cqr; dev_warn(&device->cdev->dev, "No operational channel path is left " "for the device\n"); DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last path gone"); /* First of all call extended error reporting. */ dasd_eer_write(device, NULL, DASD_EER_NOPATH); if (device->state < DASD_STATE_BASIC) return 0; /* Device is active. We want to keep it. */ list_for_each_entry(cqr, &device->ccw_queue, devlist) if ((cqr->status == DASD_CQR_IN_IO) || (cqr->status == DASD_CQR_CLEAR_PENDING)) { cqr->status = DASD_CQR_QUEUED; cqr->retries++; } dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); dasd_device_clear_timer(device); dasd_schedule_device_bh(device); return 1; } EXPORT_SYMBOL_GPL(dasd_generic_last_path_gone); int dasd_generic_path_operational(struct dasd_device *device) { dev_info(&device->cdev->dev, "A channel path to the device has become " "operational\n"); DBF_DEV_EVENT(DBF_WARNING, device, "%s", "path operational"); dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT); if (device->stopped & DASD_UNRESUMED_PM) { dasd_device_remove_stop_bits(device, DASD_UNRESUMED_PM); dasd_restore_device(device); return 1; } dasd_schedule_device_bh(device); if (device->block) dasd_schedule_block_bh(device->block); if (!device->stopped) wake_up(&generic_waitq); return 1; } EXPORT_SYMBOL_GPL(dasd_generic_path_operational); int dasd_generic_notify(struct ccw_device *cdev, int event) { struct dasd_device *device; int ret; device = dasd_device_from_cdev_locked(cdev); if (IS_ERR(device)) return 0; ret = 0; switch (event) { case CIO_GONE: case CIO_BOXED: case CIO_NO_PATH: device->path_data.opm = 0; device->path_data.ppm = 0; device->path_data.npm = 0; ret = dasd_generic_last_path_gone(device); break; case CIO_OPER: ret = 1; if (device->path_data.opm) ret = dasd_generic_path_operational(device); break; } dasd_put_device(device); return ret; } void dasd_generic_path_event(struct ccw_device *cdev, int *path_event) { int chp; __u8 oldopm, eventlpm; struct dasd_device *device; device = dasd_device_from_cdev_locked(cdev); if (IS_ERR(device)) return; for (chp = 0; chp < 8; chp++) { eventlpm = 0x80 >> chp; if (path_event[chp] & PE_PATH_GONE) { oldopm = device->path_data.opm; device->path_data.opm &= ~eventlpm; device->path_data.ppm &= ~eventlpm; device->path_data.npm &= ~eventlpm; if (oldopm && !device->path_data.opm) { dev_warn(&device->cdev->dev, "No verified channel paths remain " "for the device\n"); DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last verified path gone"); dasd_eer_write(device, NULL, DASD_EER_NOPATH); dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); } } if (path_event[chp] & PE_PATH_AVAILABLE) { device->path_data.opm &= ~eventlpm; device->path_data.ppm &= ~eventlpm; device->path_data.npm &= ~eventlpm; device->path_data.tbvpm |= eventlpm; dasd_schedule_device_bh(device); } if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) { if (!(device->path_data.opm & eventlpm) && !(device->path_data.tbvpm & eventlpm)) { /* * we can not establish a pathgroup on an * unavailable path, so trigger a path * verification first */ device->path_data.tbvpm |= eventlpm; dasd_schedule_device_bh(device); } DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Pathgroup re-established\n"); if (device->discipline->kick_validate) device->discipline->kick_validate(device); } } dasd_put_device(device); } EXPORT_SYMBOL_GPL(dasd_generic_path_event); int dasd_generic_verify_path(struct dasd_device *device, __u8 lpm) { if (!device->path_data.opm && lpm) { device->path_data.opm = lpm; dasd_generic_path_operational(device); } else device->path_data.opm |= lpm; return 0; } EXPORT_SYMBOL_GPL(dasd_generic_verify_path); int dasd_generic_pm_freeze(struct ccw_device *cdev) { struct dasd_device *device = dasd_device_from_cdev(cdev); struct list_head freeze_queue; struct dasd_ccw_req *cqr, *n; struct dasd_ccw_req *refers; int rc; if (IS_ERR(device)) return PTR_ERR(device); /* mark device as suspended */ set_bit(DASD_FLAG_SUSPENDED, &device->flags); if (device->discipline->freeze) rc = device->discipline->freeze(device); /* disallow new I/O */ dasd_device_set_stop_bits(device, DASD_STOPPED_PM); /* clear active requests and requeue them to block layer if possible */ INIT_LIST_HEAD(&freeze_queue); spin_lock_irq(get_ccwdev_lock(cdev)); rc = 0; list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { /* Check status and move request to flush_queue */ if (cqr->status == DASD_CQR_IN_IO) { rc = device->discipline->term_IO(cqr); if (rc) { /* unable to terminate requeust */ dev_err(&device->cdev->dev, "Unable to terminate request %p " "on suspend\n", cqr); spin_unlock_irq(get_ccwdev_lock(cdev)); dasd_put_device(device); return rc; } } list_move_tail(&cqr->devlist, &freeze_queue); } spin_unlock_irq(get_ccwdev_lock(cdev)); list_for_each_entry_safe(cqr, n, &freeze_queue, devlist) { wait_event(dasd_flush_wq, (cqr->status != DASD_CQR_CLEAR_PENDING)); if (cqr->status == DASD_CQR_CLEARED) cqr->status = DASD_CQR_QUEUED; /* requeue requests to blocklayer will only work for block device requests */ if (_dasd_requeue_request(cqr)) continue; /* remove requests from device and block queue */ list_del_init(&cqr->devlist); while (cqr->refers != NULL) { refers = cqr->refers; /* remove the request from the block queue */ list_del(&cqr->blocklist); /* free the finished erp request */ dasd_free_erp_request(cqr, cqr->memdev); cqr = refers; } if (cqr->block) list_del_init(&cqr->blocklist); cqr->block->base->discipline->free_cp( cqr, (struct request *) cqr->callback_data); } /* * if requests remain then they are internal request * and go back to the device queue */ if (!list_empty(&freeze_queue)) { /* move freeze_queue to start of the ccw_queue */ spin_lock_irq(get_ccwdev_lock(cdev)); list_splice_tail(&freeze_queue, &device->ccw_queue); spin_unlock_irq(get_ccwdev_lock(cdev)); } dasd_put_device(device); return rc; } EXPORT_SYMBOL_GPL(dasd_generic_pm_freeze); int dasd_generic_restore_device(struct ccw_device *cdev) { struct dasd_device *device = dasd_device_from_cdev(cdev); int rc = 0; if (IS_ERR(device)) return PTR_ERR(device); /* allow new IO again */ dasd_device_remove_stop_bits(device, (DASD_STOPPED_PM | DASD_UNRESUMED_PM)); dasd_schedule_device_bh(device); /* * call discipline restore function * if device is stopped do nothing e.g. for disconnected devices */ if (device->discipline->restore && !(device->stopped)) rc = device->discipline->restore(device); if (rc || device->stopped) /* * if the resume failed for the DASD we put it in * an UNRESUMED stop state */ device->stopped |= DASD_UNRESUMED_PM; if (device->block) dasd_schedule_block_bh(device->block); clear_bit(DASD_FLAG_SUSPENDED, &device->flags); dasd_put_device(device); return 0; } EXPORT_SYMBOL_GPL(dasd_generic_restore_device); static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, void *rdc_buffer, int rdc_buffer_size, int magic) { struct dasd_ccw_req *cqr; struct ccw1 *ccw; unsigned long *idaw; cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device); if (IS_ERR(cqr)) { /* internal error 13 - Allocating the RDC request failed*/ dev_err(&device->cdev->dev, "An error occurred in the DASD device driver, " "reason=%s\n", "13"); return cqr; } ccw = cqr->cpaddr; ccw->cmd_code = CCW_CMD_RDC; if (idal_is_needed(rdc_buffer, rdc_buffer_size)) { idaw = (unsigned long *) (cqr->data); ccw->cda = (__u32)(addr_t) idaw; ccw->flags = CCW_FLAG_IDA; idaw = idal_create_words(idaw, rdc_buffer, rdc_buffer_size); } else { ccw->cda = (__u32)(addr_t) rdc_buffer; ccw->flags = 0; } ccw->count = rdc_buffer_size; cqr->startdev = device; cqr->memdev = device; cqr->expires = 10*HZ; cqr->retries = 256; cqr->buildclk = get_tod_clock(); cqr->status = DASD_CQR_FILLED; return cqr; } int dasd_generic_read_dev_chars(struct dasd_device *device, int magic, void *rdc_buffer, int rdc_buffer_size) { int ret; struct dasd_ccw_req *cqr; cqr = dasd_generic_build_rdc(device, rdc_buffer, rdc_buffer_size, magic); if (IS_ERR(cqr)) return PTR_ERR(cqr); ret = dasd_sleep_on(cqr); dasd_sfree_request(cqr, cqr->memdev); return ret; } EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars); /* * In command mode and transport mode we need to look for sense * data in different places. The sense data itself is allways * an array of 32 bytes, so we can unify the sense data access * for both modes. */ char *dasd_get_sense(struct irb *irb) { struct tsb *tsb = NULL; char *sense = NULL; if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) { if (irb->scsw.tm.tcw) tsb = tcw_get_tsb((struct tcw *)(unsigned long) irb->scsw.tm.tcw); if (tsb && tsb->length == 64 && tsb->flags) switch (tsb->flags & 0x07) { case 1: /* tsa_iostat */ sense = tsb->tsa.iostat.sense; break; case 2: /* tsa_ddpc */ sense = tsb->tsa.ddpc.sense; break; default: /* currently we don't use interrogate data */ break; } } else if (irb->esw.esw0.erw.cons) { sense = irb->ecw; } return sense; } EXPORT_SYMBOL_GPL(dasd_get_sense); void dasd_generic_shutdown(struct ccw_device *cdev) { struct dasd_device *device; device = dasd_device_from_cdev(cdev); if (IS_ERR(device)) return; if (device->block) dasd_schedule_block_bh(device->block); dasd_schedule_device_bh(device); wait_event(shutdown_waitq, _wait_for_empty_queues(device)); } EXPORT_SYMBOL_GPL(dasd_generic_shutdown); static int __init dasd_init(void) { int rc; init_waitqueue_head(&dasd_init_waitq); init_waitqueue_head(&dasd_flush_wq); init_waitqueue_head(&generic_waitq); init_waitqueue_head(&shutdown_waitq); /* register 'common' DASD debug area, used for all DBF_XXX calls */ dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long)); if (dasd_debug_area == NULL) { rc = -ENOMEM; goto failed; } debug_register_view(dasd_debug_area, &debug_sprintf_view); debug_set_level(dasd_debug_area, DBF_WARNING); DBF_EVENT(DBF_EMERG, "%s", "debug area created"); dasd_diag_discipline_pointer = NULL; dasd_statistics_createroot(); rc = dasd_devmap_init(); if (rc) goto failed; rc = dasd_gendisk_init(); if (rc) goto failed; rc = dasd_parse(); if (rc) goto failed; rc = dasd_eer_init(); if (rc) goto failed; #ifdef CONFIG_PROC_FS rc = dasd_proc_init(); if (rc) goto failed; #endif return 0; failed: pr_info("The DASD device driver could not be initialized\n"); dasd_exit(); return rc; } module_init(dasd_init); module_exit(dasd_exit); EXPORT_SYMBOL(dasd_debug_area); EXPORT_SYMBOL(dasd_diag_discipline_pointer); EXPORT_SYMBOL(dasd_add_request_head); EXPORT_SYMBOL(dasd_add_request_tail); EXPORT_SYMBOL(dasd_cancel_req); EXPORT_SYMBOL(dasd_device_clear_timer); EXPORT_SYMBOL(dasd_block_clear_timer); EXPORT_SYMBOL(dasd_enable_device); EXPORT_SYMBOL(dasd_int_handler); EXPORT_SYMBOL(dasd_kfree_request); EXPORT_SYMBOL(dasd_kick_device); EXPORT_SYMBOL(dasd_kmalloc_request); EXPORT_SYMBOL(dasd_schedule_device_bh); EXPORT_SYMBOL(dasd_schedule_block_bh); EXPORT_SYMBOL(dasd_set_target_state); EXPORT_SYMBOL(dasd_device_set_timer); EXPORT_SYMBOL(dasd_block_set_timer); EXPORT_SYMBOL(dasd_sfree_request); EXPORT_SYMBOL(dasd_sleep_on); EXPORT_SYMBOL(dasd_sleep_on_immediatly); EXPORT_SYMBOL(dasd_sleep_on_interruptible); EXPORT_SYMBOL(dasd_smalloc_request); EXPORT_SYMBOL(dasd_start_IO); EXPORT_SYMBOL(dasd_term_IO); EXPORT_SYMBOL_GPL(dasd_generic_probe); EXPORT_SYMBOL_GPL(dasd_generic_remove); EXPORT_SYMBOL_GPL(dasd_generic_notify); EXPORT_SYMBOL_GPL(dasd_generic_set_online); EXPORT_SYMBOL_GPL(dasd_generic_set_offline); EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change); EXPORT_SYMBOL_GPL(dasd_flush_device_queue); EXPORT_SYMBOL_GPL(dasd_alloc_block); EXPORT_SYMBOL_GPL(dasd_free_block);
cneira/ebpf-backports
linux-3.10.0-514.21.1.el7.x86_64/drivers/s390/block/dasd.c
C
gpl-2.0
105,025
[ 30522, 1013, 1008, 1008, 3166, 1006, 1055, 1007, 1012, 1012, 1012, 1012, 1012, 1012, 1024, 7570, 28875, 2099, 15488, 18861, 5488, 1026, 7570, 28875, 2099, 1012, 15488, 18861, 5488, 1030, 2139, 1012, 9980, 1012, 4012, 1028, 1008, 28565, 1491...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "libplatform/impl.h" namespace mp4v2 { namespace platform { namespace io { /////////////////////////////////////////////////////////////////////////////// class StandardFileProvider : public FileProvider { public: StandardFileProvider(); bool open( std::string name, Mode mode ); bool seek( Size pos ); bool read( void* buffer, Size size, Size& nin, Size maxChunkSize ); bool write( const void* buffer, Size size, Size& nout, Size maxChunkSize ); bool close(); private: bool _seekg; bool _seekp; std::fstream _fstream; }; /////////////////////////////////////////////////////////////////////////////// StandardFileProvider::StandardFileProvider() : _seekg ( false ) , _seekp ( false ) { } bool StandardFileProvider::open( std::string name, Mode mode ) { ios::openmode om = ios::binary; switch( mode ) { case MODE_UNDEFINED: case MODE_READ: default: om |= ios::in; _seekg = true; _seekp = false; break; case MODE_MODIFY: om |= ios::in | ios::out; _seekg = true; _seekp = true; break; case MODE_CREATE: om |= ios::in | ios::out | ios::trunc; _seekg = true; _seekp = true; break; } _fstream.open( name.c_str(), om ); return _fstream.fail(); } bool StandardFileProvider::seek( Size pos ) { if( _seekg ) _fstream.seekg( pos, ios::beg ); if( _seekp ) _fstream.seekp( pos, ios::beg ); return _fstream.fail(); } bool StandardFileProvider::read( void* buffer, Size size, Size& nin, Size maxChunkSize ) { _fstream.read( (char*)buffer, size ); if( _fstream.fail() ) return true; nin = _fstream.gcount(); return false; } bool StandardFileProvider::write( const void* buffer, Size size, Size& nout, Size maxChunkSize ) { _fstream.write( (const char*)buffer, size ); if( _fstream.fail() ) return true; nout = size; return false; } bool StandardFileProvider::close() { _fstream.close(); return _fstream.fail(); } /////////////////////////////////////////////////////////////////////////////// FileProvider& FileProvider::standard() { return *new StandardFileProvider(); } /////////////////////////////////////////////////////////////////////////////// }}} // namespace mp4v2::platform::io
opsemanthano/aacgain
mp4v2/libplatform/io/File_posix.cpp
C++
gpl-2.0
2,454
[ 30522, 1001, 2421, 1000, 5622, 2497, 24759, 4017, 14192, 1013, 17727, 2140, 1012, 1044, 1000, 3415, 15327, 6131, 2549, 2615, 2475, 1063, 3415, 15327, 4132, 1063, 3415, 15327, 22834, 1063, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/********************************************************************************** * $URL$ * $Id$ *********************************************************************************** * * Copyright (c) 2005, 2006, 2007, 2008 The Sakai Foundation * * Licensed under the Educational Community 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.opensource.org/licenses/ECL-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 org.sakaiproject.portal.service; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pluto.core.PortletContextManager; import org.apache.pluto.descriptors.portlet.PortletAppDD; import org.apache.pluto.descriptors.portlet.PortletDD; import org.apache.pluto.internal.InternalPortletContext; import org.apache.pluto.spi.optional.PortletRegistryService; import org.exolab.castor.util.LocalConfiguration; import org.exolab.castor.util.Configuration.Property; import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.component.api.ServerConfigurationService; import org.sakaiproject.content.api.ContentHostingService; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.portal.api.BaseEditor; import org.sakaiproject.portal.api.Editor; import org.sakaiproject.portal.api.EditorRegistry; import org.sakaiproject.portal.api.Portal; import org.sakaiproject.portal.api.PortalHandler; import org.sakaiproject.portal.api.PortalRenderEngine; import org.sakaiproject.portal.api.PortalService; import org.sakaiproject.portal.api.PortletApplicationDescriptor; import org.sakaiproject.portal.api.PortletDescriptor; import org.sakaiproject.portal.api.SiteNeighbourhoodService; import org.sakaiproject.portal.api.StoredState; import org.sakaiproject.portal.api.StyleAbleProvider; import org.sakaiproject.site.api.Site; import org.sakaiproject.site.cover.SiteService; import org.sakaiproject.tool.api.Placement; import org.sakaiproject.tool.api.Session; import org.sakaiproject.tool.cover.SessionManager; /** * @author ieb * @since Sakai 2.4 * @version $Rev$ */ public class PortalServiceImpl implements PortalService { private static final Log log = LogFactory.getLog(PortalServiceImpl.class); /** * Parameter to force state reset */ public static final String PARM_STATE_RESET = "sakai.state.reset"; private static final String PORTAL_SKIN_NEOPREFIX_PROPERTY = "portal.neoprefix"; private static final String PORTAL_SKIN_NEOPREFIX_DEFAULT = "neo-"; private static String portalSkinPrefix; private Map<String, PortalRenderEngine> renderEngines = new ConcurrentHashMap<String, PortalRenderEngine>(); private Map<String, Map<String, PortalHandler>> handlerMaps = new ConcurrentHashMap<String, Map<String, PortalHandler>>(); private Map<String, Portal> portals = new ConcurrentHashMap<String, Portal>(); private ServerConfigurationService serverConfigurationService; private StyleAbleProvider stylableServiceProvider; private SiteNeighbourhoodService siteNeighbourhoodService; private String m_portalLinks; private ContentHostingService contentHostingService; private EditorRegistry editorRegistry; private Editor noopEditor = new BaseEditor("noop", "noop", "", ""); public void init() { try { stylableServiceProvider = (StyleAbleProvider) ComponentManager .get(StyleAbleProvider.class.getName()); serverConfigurationService = (ServerConfigurationService) ComponentManager .get(ServerConfigurationService.class.getName()); try { // configure the parser for castor.. before anything else get a // chance Properties castorProperties = LocalConfiguration.getDefault(); String parser = serverConfigurationService.getString( "sakai.xml.sax.parser", "com.sun.org.apache.xerces.internal.parsers.SAXParser"); log.info("Configured Castor to use SAX Parser " + parser); castorProperties.put(Property.Parser, parser); } catch (Exception ex) { log.error("Failed to configure Castor", ex); } portalSkinPrefix = serverConfigurationService.getString(PORTAL_SKIN_NEOPREFIX_PROPERTY, PORTAL_SKIN_NEOPREFIX_DEFAULT); if (portalSkinPrefix == null) { portalSkinPrefix = ""; } } catch (Exception ex) { } if (stylableServiceProvider == null) { log.info("No Styleable Provider found, the portal will not be stylable"); } } public StoredState getStoredState() { Session s = SessionManager.getCurrentSession(); StoredState ss = (StoredState) s.getAttribute("direct-stored-state"); log.debug("Got Stored State as [" + ss + "]"); return ss; } public void setStoredState(StoredState ss) { Session s = SessionManager.getCurrentSession(); if (s.getAttribute("direct-stored-state") == null || ss == null) { StoredState ssx = (StoredState) s.getAttribute("direct-stored-state"); log.debug("Removing Stored state " + ssx); if (ssx != null) { Exception ex = new Exception("traceback"); log.debug("Removing active Stored State Traceback gives location ", ex); } s.setAttribute("direct-stored-state", ss); log.debug(" Set StoredState as [" + ss + "]"); } } private static final String TOOLSTATE_PARAM_PREFIX = "toolstate-"; private static String computeToolStateParameterName(String placementId) { return TOOLSTATE_PARAM_PREFIX + placementId; } public String decodeToolState(Map<String, String[]> params, String placementId) { String attrname = computeToolStateParameterName(placementId); String[] attrval = params.get(attrname); return attrval == null ? null : attrval[0]; } public Map<String, String[]> encodeToolState(String placementId, String URLstub) { String attrname = computeToolStateParameterName(placementId); Map<String, String[]> togo = new HashMap<String, String[]>(); // could assemble state from other visible tools here togo.put(attrname, new String[] { URLstub }); return togo; } // To allow us to retain reset state across redirects public String getResetState() { Session s = SessionManager.getCurrentSession(); String ss = (String) s.getAttribute("reset-stored-state"); return ss; } public void setResetState(String ss) { Session s = SessionManager.getCurrentSession(); if (s.getAttribute("reset-stored-state") == null || ss == null) { s.setAttribute("reset-stored-state", ss); } } public boolean isEnableDirect() { boolean directEnable = "true".equals(serverConfigurationService.getString( "charon.directurl", "true")); log.debug("Direct Enable is " + directEnable); return directEnable; } public boolean isResetRequested(HttpServletRequest req) { return "true".equals(req.getParameter(PARM_STATE_RESET)) || "true".equals(getResetState()); } public String getResetStateParam() { // TODO Auto-generated method stub return PARM_STATE_RESET; } public StoredState newStoredState(String marker, String replacement) { log.debug("Storing State for Marker=[" + marker + "] replacement=[" + replacement + "]"); return new StoredStateImpl(marker, replacement); } public Iterator<PortletApplicationDescriptor> getRegisteredApplications() { PortletRegistryService registry = PortletContextManager.getManager(); final Iterator apps = registry.getRegisteredPortletApplications(); return new Iterator<PortletApplicationDescriptor>() { public boolean hasNext() { return apps.hasNext(); } public PortletApplicationDescriptor next() { final InternalPortletContext pc = (InternalPortletContext) apps.next(); final PortletAppDD appDD = pc.getPortletApplicationDefinition(); return new PortletApplicationDescriptor() { public String getApplicationContext() { return pc.getPortletContextName(); } public String getApplicationId() { return pc.getApplicationId(); } public String getApplicationName() { return pc.getApplicationId(); } public Iterator<PortletDescriptor> getPortlets() { if (appDD != null) { List portlets = appDD.getPortlets(); final Iterator portletsI = portlets.iterator(); return new Iterator<PortletDescriptor>() { public boolean hasNext() { return portletsI.hasNext(); } public PortletDescriptor next() { final PortletDD pdd = (PortletDD) portletsI.next(); return new PortletDescriptor() { public String getPortletId() { return pdd.getPortletName(); } public String getPortletName() { return pdd.getPortletName(); } }; } public void remove() { } }; } else { log.warn(" Portlet Application has no portlets " + pc.getPortletContextName()); return new Iterator<PortletDescriptor>() { public boolean hasNext() { return false; } public PortletDescriptor next() { return null; } public void remove() { } }; } } }; } public void remove() { } }; } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#getRenderEngine(javax.servlet.http.HttpServletRequest) */ public PortalRenderEngine getRenderEngine(String context, HttpServletRequest request) { // at this point we ignore request but we might use ut to return more // than one render engine if (context == null || context.length() == 0) { context = Portal.DEFAULT_PORTAL_CONTEXT; } return (PortalRenderEngine) renderEngines.get(context); } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#addRenderEngine(org.sakaiproject.portal.api.PortalRenderEngine) */ public void addRenderEngine(String context, PortalRenderEngine vengine) { renderEngines.put(context, vengine); } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#removeRenderEngine(org.sakaiproject.portal.api.PortalRenderEngine) */ public void removeRenderEngine(String context, PortalRenderEngine vengine) { renderEngines.remove(context); } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#addHandler(java.lang.String, * org.sakaiproject.portal.api.PortalHandler) */ public void addHandler(Portal portal, PortalHandler handler) { String portalContext = portal.getPortalContext(); Map<String, PortalHandler> handlerMap = getHandlerMap(portal); String urlFragment = handler.getUrlFragment(); PortalHandler ph = handlerMap.get(urlFragment); if (ph != null) { handler.deregister(portal); log.warn("Handler Present on " + urlFragment + " will replace " + ph + " with " + handler); } handler.register(portal, this, portal.getServletContext()); handlerMap.put(urlFragment, handler); log.info("URL " + portalContext + ":/" + urlFragment + " will be handled by " + handler); } public void addHandler(String portalContext, PortalHandler handler) { Portal portal = portals.get(portalContext); if (portal == null) { Map<String, PortalHandler> handlerMap = getHandlerMap(portalContext, true); handlerMap.put(handler.getUrlFragment(), handler); log.debug("Registered handler ("+ handler+ ") for portal ("+portalContext+ ") that doesn't yet exist."); } else { addHandler(portal, handler); } } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#getHandlerMap(java.lang.String) */ public Map<String, PortalHandler> getHandlerMap(Portal portal) { return getHandlerMap(portal.getPortalContext(), true); } private Map<String, PortalHandler> getHandlerMap(String portalContext, boolean create) { Map<String, PortalHandler> handlerMap = handlerMaps.get(portalContext); if (create && handlerMap == null) { handlerMap = new ConcurrentHashMap<String, PortalHandler>(); handlerMaps.put(portalContext, handlerMap); } return handlerMap; } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#removeHandler(java.lang.String, * java.lang.String) This method it NOT thread safe, but the likelyhood * of a co */ public void removeHandler(Portal portal, String urlFragment) { Map<String, PortalHandler> handlerMap = getHandlerMap(portal.getPortalContext(), false); if (handlerMap != null) { PortalHandler ph = handlerMap.get(urlFragment); if (ph != null) { ph.deregister(portal); handlerMap.remove(urlFragment); log.warn("Handler Present on " + urlFragment + " " + ph + " will be removed "); } } } public void removeHandler(String portalContext, String urlFragment) { Portal portal = portals.get(portalContext); if (portal == null) { log.warn("Attempted to remove handler("+ urlFragment+ ") from non existent portal ("+portalContext+")"); } else { removeHandler(portal, urlFragment); } } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#addPortal(org.sakaiproject.portal.api.Portal) */ public void addPortal(Portal portal) { String portalContext = portal.getPortalContext(); portals.put(portalContext, portal); // reconnect any handlers Map<String, PortalHandler> phm = getHandlerMap(portal); for (Iterator<PortalHandler> pIterator = phm.values().iterator(); pIterator .hasNext();) { PortalHandler ph = pIterator.next(); ph.register(portal, this, portal.getServletContext()); } } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#removePortal(org.sakaiproject.portal.api.Portal) */ public void removePortal(Portal portal) { String portalContext = portal.getPortalContext(); portals.remove(portalContext); } /* * (non-Javadoc) * * @see org.sakaiproject.portal.api.PortalService#getStylableService() */ public StyleAbleProvider getStylableService() { return stylableServiceProvider; } /* (non-Javadoc) * @see org.sakaiproject.portal.api.PortalService#getSiteNeighbourhoodService() */ public SiteNeighbourhoodService getSiteNeighbourhoodService() { return siteNeighbourhoodService; } /** * @param siteNeighbourhoodService the siteNeighbourhoodService to set */ public void setSiteNeighbourhoodService(SiteNeighbourhoodService siteNeighbourhoodService) { this.siteNeighbourhoodService = siteNeighbourhoodService; } /* optional portal links for portal header (SAK-22912) */ public String getPortalLinks() { return m_portalLinks; } public ContentHostingService getContentHostingService() { return contentHostingService; } /** * @param portalLinks the portal icons to set */ public void setPortalLinks(String portalLinks) { m_portalLinks = portalLinks; } public void setContentHostingService(ContentHostingService contentHostingService) { this.contentHostingService = contentHostingService; } public String getBrowserCollectionId(Placement placement) { String collectionId = null; if (placement != null) { collectionId = getContentHostingService().getSiteCollection(placement.getContext()); } if (collectionId == null) { collectionId = getContentHostingService().getSiteCollection("~" + SessionManager.getCurrentSessionUserId()); } return collectionId; } public Editor getActiveEditor() { return getActiveEditor(null); } public Editor getActiveEditor(Placement placement) { String systemEditor = serverConfigurationService.getString("wysiwyg.editor", "ckeditor"); String activeEditor = systemEditor; if (placement != null) { //Allow tool- or user-specific editors? try { Site site = SiteService.getSite(placement.getContext()); Object o = site.getProperties().get("wysiwyg.editor"); if (o != null) { activeEditor = o.toString(); } } catch (IdUnusedException ex) { if (log.isDebugEnabled()) { log.debug(ex.getMessage()); } } } Editor editor = getEditorRegistry().getEditor(activeEditor); if (editor == null) { // Load a base no-op editor so sakai.editor.launch calls succeed. // We may decide to offer some textarea infrastructure as well. In // this case, there are editor and launch files being consulted // already from /library/, which is easier to patch and deploy. editor = getEditorRegistry().getEditor("textarea"); } if (editor == null) { // If, for some reason, our stub editor is null, give an instance // that doesn't even try to load files. This will result in script // errors because sakai.editor.launch will not be defined, but // this way, we can't suffer NPEs. In some cases, this degradation // will be graceful enough that the page can function. editor = noopEditor; } return editor; } public EditorRegistry getEditorRegistry() { return editorRegistry; } public void setEditorRegistry(EditorRegistry editorRegistry) { this.editorRegistry = editorRegistry; } public String getSkinPrefix() { return portalSkinPrefix; } }
marktriggs/nyu-sakai-10.4
portal/portal-service-impl/impl/src/java/org/sakaiproject/portal/service/PortalServiceImpl.java
Java
apache-2.0
17,816
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* This file is generated and updated by Sencha Cmd. You can edit this file as needed for your application, but these edits will have to be merged by Sencha Cmd when it performs code generation tasks such as generating new models, controllers or views and when running "sencha app upgrade". Ideally changes to this file would be limited and most work would be done in other places (such as Controllers). If Sencha Cmd cannot merge your changes and its generated code, it will produce a "merge conflict" that you will need to resolve manually. */ Ext.application({ name: 'SenchaBDD', requires: [ 'Ext.MessageBox' ], controllers: [ 'Login', 'Main' ], views: [ 'ColorsList', 'Login', 'Main', ], stores: [ 'Colors' ], icon: { '57': 'resources/icons/Icon.png', '72': 'resources/icons/Icon~ipad.png', '114': 'resources/icons/Icon@2x.png', '144': 'resources/icons/Icon~ipad@2x.png' }, isIconPrecomposed: true, startupImage: { '320x460': 'resources/startup/320x460.jpg', '640x920': 'resources/startup/640x920.png', '768x1004': 'resources/startup/768x1004.png', '748x1024': 'resources/startup/748x1024.png', '1536x2008': 'resources/startup/1536x2008.png', '1496x2048': 'resources/startup/1496x2048.png' }, launch: function() { // Destroy the #appLoadingIndicator element Ext.fly('appLoadingIndicator').destroy(); // Initialize the login view Ext.Viewport.add(Ext.create('SenchaBDD.view.Login')); }, onUpdated: function() { Ext.Msg.confirm( "Application Update", "This application has just successfully been updated to the latest version. Reload now?", function(buttonId) { if (buttonId === 'yes') { window.location.reload(); } } ); } });
m-revetria/sencha-touch-bdd-example
app.js
JavaScript
gpl-2.0
2,037
[ 30522, 1013, 1008, 2023, 5371, 2003, 7013, 1998, 7172, 2011, 12411, 7507, 4642, 2094, 1012, 2017, 2064, 10086, 2023, 5371, 2004, 2734, 2005, 2115, 4646, 1010, 2021, 2122, 10086, 2015, 2097, 2031, 2000, 2022, 5314, 2011, 12411, 7507, 4642, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import React from "react"; import ReactDOM from "react-dom"; import VariableInspector from "./components/VariableInspector"; ReactDOM.render( <VariableInspector />, document.getElementById("root") );
agermanidis/livepython
src/variable_inspector.js
JavaScript
mit
206
[ 30522, 12324, 10509, 2013, 1000, 10509, 1000, 1025, 12324, 10509, 9527, 2013, 1000, 10509, 1011, 14383, 1000, 1025, 12324, 8023, 7076, 5051, 16761, 2013, 1000, 1012, 1013, 6177, 1013, 8023, 7076, 5051, 16761, 1000, 1025, 10509, 9527, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import * as _ from 'lodash'; import Vuex from 'vuex'; import {Deck} from '../models/Deck' import DeckState from '../models/state/DeckState' const store = { state: new DeckState(), mutations: { addToDeck(state, card) { if (!card) { return; } state.currentDeck.cards.push(card); if (!_.some(state.allDecks, thatDeck => thatDeck == state.currentDeck)) { state.allDecks.push(state.currentDeck); } localStorage["currentDeck"] = JSON.stringify(state.currentDeck); }, removeFromDeck(state, card) { if (card == undefined) { return; } let cardIndex = state.currentDeck.cards.indexOf(card); if (cardIndex < 0) { return; } state.currentDeck.cards.splice(cardIndex, 1); localStorage["currentDeck"] = JSON.stringify(state.currentDeck); }, removeAllFromDeck(state, card) { if (card == undefined) { return; } var filtered = state.currentDeck.cards.filter(c => c.multiverseid != card.multiverseid); state.currentDeck.cards = filtered; localStorage["currentDeck"] = JSON.stringify(state.currentDeck); }, loadDeck(state, deck) { if (deck == undefined) { return; } state.allDecks.push(deck); state.currentDeck = state.allDecks[state.allDecks.length - 1]; }, deleteCurrentDeck(state) { var deckIndex = state.allDecks.indexOf(state.currentDeck); state.allDecks.splice(deckIndex, 1); }, clearDeck(state) { state.currentDeck.cards = []; localStorage["currentDeck"] = JSON.stringify(state.currentDeck); }, setCurrentDeck(state, deck) { if (deck == undefined) { return; } state.currentDeck = deck; localStorage["currentDeck"] = JSON.stringify(state.currentDeck); } } }; export default store
jmazouri/Deckard
Deckard/Frontend/src/deckard/state/DeckModule.ts
TypeScript
mit
2,091
[ 30522, 12324, 1008, 2004, 1035, 2013, 1005, 8840, 8883, 2232, 1005, 1025, 12324, 24728, 10288, 2013, 1005, 24728, 10288, 1005, 1025, 12324, 1063, 5877, 1065, 2013, 1005, 1012, 1012, 1013, 4275, 1013, 5877, 1005, 12324, 19963, 12259, 2013, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2000-2009 JetBrains s.r.o. * * 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 com.intellij.application.options.colors; import com.intellij.ui.ListScrollingUtil; import com.intellij.util.EventDispatcher; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashSet; import java.util.Set; public class OptionsPanelImpl extends JPanel implements OptionsPanel { private final JList myOptionsList; private final ColorAndFontDescriptionPanel myOptionsPanel; private final ColorAndFontOptions myOptions; private final SchemesPanel mySchemesProvider; private final String myCategoryName; private final EventDispatcher<ColorAndFontSettingsListener> myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class); public OptionsPanelImpl(ColorAndFontDescriptionPanel optionsPanel, ColorAndFontOptions options, SchemesPanel schemesProvider, String categoryName) { super(new BorderLayout()); myOptions = options; mySchemesProvider = schemesProvider; myCategoryName = categoryName; optionsPanel.addActionListener(new ActionListener(){ public void actionPerformed(final ActionEvent e) { myDispatcher.getMulticaster().settingsChanged(); } }); myOptionsList = new JList(); myOptionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!mySchemesProvider.areSchemesLoaded()) return; processListValueChanged(); } }); myOptionsList.setCellRenderer(new DefaultListCellRenderer(){ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof ColorAndFontDescription) { setIcon(((ColorAndFontDescription)value).getIcon()); setToolTipText(((ColorAndFontDescription)value).getToolTip()); } return component; } }); myOptionsList.setModel(new DefaultListModel()); myOptionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = new JScrollPane(myOptionsList); scrollPane.setPreferredSize(new Dimension(230, 60)); JPanel north = new JPanel(new BorderLayout()); north.add(scrollPane, BorderLayout.WEST); north.add(optionsPanel, BorderLayout.CENTER); myOptionsPanel = optionsPanel; add(north, BorderLayout.NORTH); } public void addListener(ColorAndFontSettingsListener listener) { myDispatcher.addListener(listener); } private void processListValueChanged() { Object selectedValue = myOptionsList.getSelectedValue(); ColorAndFontDescription description = (ColorAndFontDescription)selectedValue; ColorAndFontDescriptionPanel optionsPanel = myOptionsPanel; if (description == null) { optionsPanel.resetDefault(); return; } optionsPanel.reset(description); myDispatcher.getMulticaster().selectedOptionChanged(description); } private void fillOptionsList() { int selIndex = myOptionsList.getSelectedIndex(); DefaultListModel listModel = (DefaultListModel)myOptionsList.getModel(); listModel.removeAllElements(); EditorSchemeAttributeDescriptor[] descriptions = myOptions.getCurrentDescriptions(); for (EditorSchemeAttributeDescriptor description : descriptions) { if (description.getGroup().equals(myCategoryName)) { listModel.addElement(description); } } if (selIndex >= 0) { myOptionsList.setSelectedIndex(selIndex); } ListScrollingUtil.ensureSelectionExists(myOptionsList); Object selected = myOptionsList.getSelectedValue(); if (selected instanceof EditorSchemeAttributeDescriptor) { myDispatcher.getMulticaster().selectedOptionChanged(selected); } } public JPanel getPanel() { return this; } public void updateOptionsList() { fillOptionsList(); processListValueChanged(); } public Runnable showOption(final String option) { DefaultListModel model = (DefaultListModel)myOptionsList.getModel(); for (int i = 0; i < model.size(); i++) { Object o = model.get(i); if (o instanceof EditorSchemeAttributeDescriptor) { String type = ((EditorSchemeAttributeDescriptor)o).getType(); if (type.toLowerCase().contains(option.toLowerCase())) { final int i1 = i; return new Runnable() { public void run() { ListScrollingUtil.selectItem(myOptionsList, i1); } }; } } } return null; } public void applyChangesToScheme() { Object selectedValue = myOptionsList.getSelectedValue(); if (selectedValue instanceof ColorAndFontDescription) { myOptionsPanel.apply((ColorAndFontDescription)selectedValue,myOptions.getSelectedScheme()); } } public void selectOption(final String typeToSelect) { DefaultListModel model = (DefaultListModel)myOptionsList.getModel(); for (int i = 0; i < model.size(); i++) { Object o = model.get(i); if (o instanceof EditorSchemeAttributeDescriptor) { if (typeToSelect.equals(((EditorSchemeAttributeDescriptor)o).getType())) { ListScrollingUtil.selectItem(myOptionsList, i); return; } } } } public Set<String> processListOptions() { HashSet<String> result = new HashSet<String>(); EditorSchemeAttributeDescriptor[] descriptions = myOptions.getCurrentDescriptions(); for (EditorSchemeAttributeDescriptor description : descriptions) { if (description.getGroup().equals(myCategoryName)) { result.add(description.toString()); } } return result; } }
jexp/idea2
platform/lang-impl/src/com/intellij/application/options/colors/OptionsPanelImpl.java
Java
apache-2.0
6,502
[ 30522, 1013, 1008, 1008, 9385, 2456, 1011, 2268, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!doctype html> <html lang="en"> <head> <title>jQuery UI Resizable - Snap to grid</title> <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" /> <script type="text/javascript" src="../../jquery-1.3.2.js"></script> <script type="text/javascript" src="../../ui/ui.core.js"></script> <script type="text/javascript" src="../../ui/ui.resizable.js"></script> <link type="text/css" href="../demos.css" rel="stylesheet" /> <style type="text/css"> #resizable { width: 150px; height: 150px; padding: 0.5em; } #resizable h3 { text-align: center; margin: 0; } </style> <script type="text/javascript"> $(function() { $("#resizable").resizable({ grid: 50 }); }); </script> </head> <body> <div class="demo"> <div id="resizable" class="ui-widget-content"> <h3 class="ui-widget-header">Grid</h3> </div> </div><!-- End demo --> <div class="demo-description"> <p>Snap the resizable element to a grid. Set the dimensions of grid cells (height and width in pixels) with the <code>grid</code> option.</p> </div><!-- End demo-description --> </body> </html>
cefn/allyourx
website/data/assets/examples/lib/jquery-ui-1.7.2/demos/resizable/snap-to-grid.html
HTML
gpl-3.0
1,124
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 1046, 4226, 2854, 21318, 24501, 21335, 3468, 1011, 10245, 2000, 8370, 1026, 1013, 2516, 1028, 1026, 4957, 2828...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // CategoryModel.h // healthfood // // Created by lanou on 15/6/22. // Copyright (c) 2015年 hastar. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface CategoryModel : NSObject @property (nonatomic, retain)NSString *title; @property (nonatomic, retain)UIImage *image; @property (nonatomic, retain)NSArray *idArray; -(instancetype)initWithTitle:(NSString *)title andImageName:(NSString *)imageName andIdArray:(NSArray *)array; @end
hastar/healthFood
healthfood/Model/CategoryModel.h
C
gpl-2.0
486
[ 30522, 1013, 1013, 1013, 1013, 4696, 5302, 9247, 1012, 1044, 1013, 1013, 2740, 14876, 7716, 1013, 1013, 1013, 1013, 2580, 2011, 17595, 7140, 2006, 2321, 1013, 1020, 1013, 2570, 1012, 1013, 1013, 9385, 1006, 1039, 1007, 2325, 1840, 2038, 7...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module Web::Controllers::Books class Create include Web::Action expose :book params do param :book do param :title, presence: true param :author, presence: true end end def call(params) if params.valid? @book = BookRepository.create(Book.new(params[:book])) redirect_to routes.books_path end end end end
matiasleidemer/lotus-bookshelf
apps/web/controllers/books/create.rb
Ruby
mit
393
[ 30522, 11336, 4773, 1024, 1024, 21257, 1024, 1024, 2808, 2465, 3443, 2421, 4773, 1024, 1024, 2895, 14451, 1024, 2338, 11498, 5244, 2079, 11498, 2213, 1024, 2338, 2079, 11498, 2213, 1024, 2516, 1010, 3739, 1024, 2995, 11498, 2213, 1024, 3166...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * @license Apache-2.0 * * Copyright (c) 2018 The Stdlib Authors. * * 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. */ 'use strict'; // MODULES // var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var Float64Array = require( '@stdlib/array/float64' ); var minmaxabs = require( './../lib' ); // TESTS // tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); t.strictEqual( typeof minmaxabs, 'function', 'main export is a function' ); t.end(); }); tape( 'the function returns `NaN` for both the minimum and maximum absolute value if provided a `NaN`', function test( t ) { var v; v = minmaxabs( NaN, 3.14 ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( 3.14, NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( NaN, NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( 3.14, 4.2, NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( NaN, 4.2, NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); v = minmaxabs( NaN, NaN, NaN ); t.strictEqual( isnan( v[ 0 ] ), true, 'returns NaN' ); t.strictEqual( isnan( v[ 1 ] ), true, 'returns NaN' ); t.end(); }); tape( 'the function returns `Infinity` as the maximum value if provided `-Infinity`', function test( t ) { var v; v = minmaxabs( NINF, 3.14 ); t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); v = minmaxabs( 3.14, NINF ); t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); v = minmaxabs( NINF ); t.strictEqual( v[ 0 ], PINF, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); v = minmaxabs( 3.14, 4.2, NINF ); t.strictEqual( v[ 0 ], 3.14, 'returns exected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', function test( t ) { var v; v = minmaxabs( PINF, 3.14 ); t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); v = minmaxabs( 3.14, PINF ); t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); v = minmaxabs( PINF ); t.strictEqual( v[ 0 ], PINF, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns +infinity' ); v = minmaxabs( 3.14, 4.2, PINF ); t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns correctly signed zeros', function test( t ) { var v; v = minmaxabs( +0.0, -0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( -0.0, +0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( -0.0, -0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( +0.0, +0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( -0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( +0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); v = minmaxabs( +0.0, -0.0, +0.0 ); t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); t.end(); }); tape( 'the function returns the minimum and maximum absolute values', function test( t ) { var v; v = minmaxabs( 4.2, 3.14 ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); v = minmaxabs( -4.2, 3.14 ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); v = minmaxabs( 3.14 ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); v = minmaxabs( PINF ); t.strictEqual( v[ 0 ], PINF, 'returns min value' ); t.strictEqual( v[ 1 ], PINF, 'returns max value' ); v = minmaxabs( 4.2, 3.14, -1.0 ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); v = minmaxabs( 4.2, 3.14, -1.0, -6.14 ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 6.14, 'returns max value' ); t.end(); }); tape( 'the function supports providing an output object (array)', function test( t ) { var out; var v; out = [ 0.0, 0.0 ]; v = minmaxabs( out, 4.2, 3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = [ 0.0, 0.0 ]; v = minmaxabs( out, -4.2, -3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = [ 0.0, 0.0 ]; v = minmaxabs( out, 3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); out = [ 0.0, 0.0 ]; v = minmaxabs( out, PINF ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], PINF, 'returns min value' ); t.strictEqual( v[ 1 ], PINF, 'returns max value' ); out = [ 0.0, 0.0 ]; v = minmaxabs( out, 4.2, 3.14, -1.0 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = [ 0.0, 0.0 ]; v = minmaxabs( out, 4.2, 3.14, -1.0, -6.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 6.14, 'returns max value' ); t.end(); }); tape( 'the function supports providing an output object (typed array)', function test( t ) { var out; var v; out = new Float64Array( 2 ); v = minmaxabs( out, 4.2, 3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = new Float64Array( 2 ); v = minmaxabs( out, -4.2, 3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = new Float64Array( 2 ); v = minmaxabs( out, 3.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); out = new Float64Array( 2 ); v = minmaxabs( out, PINF ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], PINF, 'returns min value' ); t.strictEqual( v[ 1 ], PINF, 'returns max value' ); out = new Float64Array( 2 ); v = minmaxabs( out, 4.2, 3.14, -1.0 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); out = new Float64Array( 2 ); v = minmaxabs( out, 4.2, 3.14, -1.0, -6.14 ); t.strictEqual( v, out, 'returns output array' ); t.strictEqual( v[ 0 ], 1.0, 'returns min value' ); t.strictEqual( v[ 1 ], 6.14, 'returns max value' ); t.end(); });
stdlib-js/stdlib
lib/node_modules/@stdlib/math/base/special/minmaxabs/test/test.js
JavaScript
apache-2.0
8,786
[ 30522, 1013, 1008, 1008, 1008, 1030, 6105, 15895, 1011, 1016, 1012, 1014, 1008, 1008, 9385, 1006, 1039, 1007, 2760, 1996, 2358, 19422, 12322, 6048, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 30524, 1999, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module ToppingsRails VERSION = "0.0.1" end
toppings/toppings-rails
lib/toppings_rails/version.rb
Ruby
mit
45
[ 30522, 11336, 22286, 21338, 12502, 2015, 2544, 1027, 1000, 1014, 1012, 1014, 1012, 1015, 1000, 2203, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * XXL: The eXtensible and fleXible Library for data processing * * Copyright (C) 2000-2011 Prof. Dr. Bernhard Seeger Head of the Database Research Group Department * of Mathematics and Computer Science University of Marburg Germany * * This library is free software; you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library; * If not, see <http://www.gnu.org/licenses/>. * * http://code.google.com/p/xxl/ */ package xxl.core.indexStructures.keyRanges; import xxl.core.functions.AbstractFunction; import xxl.core.functions.Function; import xxl.core.indexStructures.BPlusTree.KeyRange; /** * {@link xxl.core.indexStructures.BPlusTree.KeyRange KeyRange} represents key ranges (i.e. * intervals of keys). It is used to specify (range) queries on the <tt>BPlusTree</tt> and to hold * the key range of the data objects stored in the tree in the member field <tt>rootDescriptor</tt>.<br/> * <br/> * * This class extends <tt>KeyRange</tt> for using <b>Shorts</b> as keys.<br/> * <br/> * * You will find a <b>list of all available implemented KeyRanges</b> in * {@link xxl.core.indexStructures.keyRanges.KeyRangeFactory KeyRangeFactory} class. * * @author Marcus Pinnecke (pinnecke@mathematik.uni-marburg.de) * * @see xxl.core.indexStructures.BPlusTree.KeyRange */ public class ShortKeyRange extends KeyRange { /** * Used for a functional like programming style which creates in this case a new ranges. */ public static Function<Object, ShortKeyRange> FACTORY_FUNCTION = new AbstractFunction<Object, ShortKeyRange>() { @Override public ShortKeyRange invoke(Object argument0, Object argument1) { return new ShortKeyRange((Short) argument0, (Short) argument1); } }; /** * @see xxl.core.indexStructures.BPlusTree.KeyRange */ public ShortKeyRange(short min, short max) { super(min, max); } /** * @see xxl.core.indexStructures.BPlusTree.KeyRange */ public ShortKeyRange(Short min, Short max) { super(min, max); } @Override public Object clone() { return new ShortKeyRange(new Short((Short) this.sepValue), new Short( (Short) this.maxBound)); } }
hannoman/xxl
src/xxl/core/indexStructures/keyRanges/ShortKeyRange.java
Java
lgpl-3.0
2,702
[ 30522, 1013, 1008, 1008, 22038, 2140, 1024, 1996, 4654, 25808, 7028, 1998, 12379, 3075, 2005, 2951, 6364, 1008, 1008, 9385, 1006, 1039, 1007, 2456, 1011, 2249, 11268, 1012, 2852, 1012, 21432, 2156, 4590, 2132, 1997, 1996, 7809, 2470, 2177, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Didymocarpus reniformis W.T. Wang SPECIES #### Status ACCEPTED #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Magnoliopsida/Lamiales/Gesneriaceae/Didymocarpus/Didymocarpus reniformis/README.md
Markdown
apache-2.0
191
[ 30522, 1001, 2106, 24335, 24755, 14536, 2271, 14916, 22631, 2483, 1059, 1012, 1056, 1012, 7418, 2427, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 1996, 10161, 1997, 2166, 1010, 3822, 2254, 2249, 1001, 1001, 1001,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # 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. import distutils.version as dist_version import os import sys from dragon.db.sqlalchemy.session import get_engine from dragon.db import migration import sqlalchemy import migrate from migrate.versioning import util as migrate_util from dragon.openstack.common import exception from dragon.openstack.common.gettextutils import _ _REPOSITORY = None @migrate_util.decorator def patched_with_engine(f, *a, **kw): url = a[0] engine = migrate_util.construct_engine(url, **kw) try: kw['engine'] = engine return f(*a, **kw) finally: if isinstance(engine, migrate_util.Engine) and engine is not url: migrate_util.log.debug('Disposing SQLAlchemy engine %s', engine) engine.dispose() # TODO(jkoelker) When migrate 0.7.3 is released and nova depends # on that version or higher, this can be removed MIN_PKG_VERSION = dist_version.StrictVersion('0.7.3') if (not hasattr(migrate, '__version__') or dist_version.StrictVersion(migrate.__version__) < MIN_PKG_VERSION): migrate_util.with_engine = patched_with_engine # NOTE(jkoelker) Delay importing migrate until we are patched from migrate.versioning import api as versioning_api from migrate.versioning.repository import Repository try: from migrate.versioning import exceptions as versioning_exceptions except ImportError: try: from migrate import exceptions as versioning_exceptions except ImportError: sys.exit(_("python-migrate is not installed. Exiting.")) #_REPOSITORY = None def db_sync(version=None): if version is not None: try: version = int(version) except ValueError: raise exception.Error(_("version should be an integer")) current_version = db_version() repository = _find_migrate_repo() if version is None or version > current_version: return versioning_api.upgrade(get_engine(), repository, version) else: return versioning_api.downgrade(get_engine(), repository, version) def db_version(): repository = _find_migrate_repo() try: return versioning_api.db_version(get_engine(), repository) except versioning_exceptions.DatabaseNotControlledError as exc: # If we aren't version controlled there may be an existing, # non-version controlled database present. meta = sqlalchemy.MetaData() engine = get_engine() meta.reflect(bind=engine) tables = meta.tables if len(tables): raise exc db_version_control(migration.INIT_VERSION) return versioning_api.db_version(get_engine(), repository) def db_version_control(version=None): repository = _find_migrate_repo() versioning_api.version_control(get_engine(), repository, version) return version def _find_migrate_repo(): """Get the path for the migrate repository.""" path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'migrate_repo') assert os.path.exists(path) global _REPOSITORY if _REPOSITORY is None: _REPOSITORY = Repository(path) return _REPOSITORY
os-cloud-storage/openstack-workload-disaster-recovery
dragon/db/sqlalchemy/migration.py
Python
apache-2.0
3,810
[ 30522, 1001, 6819, 2213, 1024, 21628, 16033, 2361, 1027, 1018, 5670, 9148, 11927, 2232, 1027, 1018, 3730, 2696, 5910, 14399, 1027, 1018, 1001, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
body { background: #ffffff; } .hll { background-color: #ffffcc } .c { color: #888888 } /* Comment */ .err { color: #FF0000; background-color: #FFAAAA } /* Error */ .k { color: #008800; font-weight: bold } /* Keyword */ .o { color: #333333 } /* Operator */ .cm { color: #888888 } /* Comment.Multiline */ .cp { color: #557799 } /* Comment.Preproc */ .c1 { color: #888888 } /* Comment.Single */ .cs { color: #cc0000; font-weight: bold } /* Comment.Special */ .gd { color: #A00000 } /* Generic.Deleted */ .ge { font-style: italic } /* Generic.Emph */ .gr { color: #FF0000 } /* Generic.Error */ .gh { color: #000080; font-weight: bold } /* Generic.Heading */ .gi { color: #00A000 } /* Generic.Inserted */ .go { color: #888888 } /* Generic.Output */ .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ .gs { font-weight: bold } /* Generic.Strong */ .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ .gt { color: #0044DD } /* Generic.Traceback */ .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .kp { color: #003388; font-weight: bold } /* Keyword.Pseudo */ .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .kt { color: #333399; font-weight: bold } /* Keyword.Type */ .m { color: #6600EE; font-weight: bold } /* Literal.Number */ .s { background-color: #fff0f0 } /* Literal.String */ .na { color: #0000CC } /* Name.Attribute */ .nb { color: #007020 } /* Name.Builtin */ .nc { color: #BB0066; font-weight: bold } /* Name.Class */ .no { color: #003366; font-weight: bold } /* Name.Constant */ .nd { color: #555555; font-weight: bold } /* Name.Decorator */ .ni { color: #880000; font-weight: bold } /* Name.Entity */ .ne { color: #FF0000; font-weight: bold } /* Name.Exception */ .nf { color: #0066BB; font-weight: bold } /* Name.Function */ .nl { color: #997700; font-weight: bold } /* Name.Label */ .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ .nt { color: #007700 } /* Name.Tag */ .nv { color: #996633 } /* Name.Variable */ .ow { color: #000000; font-weight: bold } /* Operator.Word */ .w { color: #bbbbbb } /* Text.Whitespace */ .mf { color: #6600EE; font-weight: bold } /* Literal.Number.Float */ .mh { color: #005588; font-weight: bold } /* Literal.Number.Hex */ .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .mo { color: #4400EE; font-weight: bold } /* Literal.Number.Oct */ .sb { background-color: #fff0f0 } /* Literal.String.Backtick */ .sc { color: #0044DD } /* Literal.String.Char */ .sd { color: #DD4422 } /* Literal.String.Doc */ .s2 { background-color: #fff0f0 } /* Literal.String.Double */ .se { color: #666666; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */ .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */ .si { background-color: #eeeeee } /* Literal.String.Interpol */ .sx { color: #DD2200; background-color: #fff0f0 } /* Literal.String.Other */ .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */ .s1 { background-color: #fff0f0 } /* Literal.String.Single */ .ss { color: #AA6600 } /* Literal.String.Symbol */ .bp { color: #007020 } /* Name.Builtin.Pseudo */ .vc { color: #336699 } /* Name.Variable.Class */ .vg { color: #dd7700; font-weight: bold } /* Name.Variable.Global */ .vi { color: #3333BB } /* Name.Variable.Instance */ .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
cinghiopinghio/pytheme
data/style.css
CSS
gpl-3.0
3,519
[ 30522, 2303, 1063, 4281, 1024, 1001, 21461, 4246, 4246, 1025, 1065, 1012, 1044, 3363, 1063, 4281, 1011, 3609, 1024, 1001, 21461, 4246, 9468, 1065, 1012, 1039, 1063, 3609, 1024, 1001, 6070, 2620, 2620, 2620, 2620, 1065, 1013, 1008, 7615, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# AUTOGENERATED FILE FROM balenalib/photon-nano-debian:stretch-run # remove several traces of debian python RUN apt-get purge -y python.* # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. ENV LANG C.UTF-8 # install python dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ netbase \ && rm -rf /var/lib/apt/lists/* # key 63C7CC90: public key "Simon McVittie <smcv@pseudorandom.co.uk>" imported # key 3372DCFA: public key "Donald Stufft (dstufft) <donald@stufft.io>" imported RUN gpg --batch --keyserver keyring.debian.org --recv-keys 4DE8FF2A63C7CC90 \ && gpg --batch --keyserver keyserver.ubuntu.com --recv-key 6E3CBCE93372DCFA \ && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 0x52a43a1e4b77b059 ENV PYTHON_VERSION 3.8.12 # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" ENV PYTHON_PIP_VERSION 21.3.1 ENV SETUPTOOLS_VERSION 60.5.4 RUN set -x \ && buildDeps=' \ curl \ ' \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -SLO "http://resin-packages.s3.amazonaws.com/python/v$PYTHON_VERSION/Python-$PYTHON_VERSION.linux-aarch64-libffi3.2.tar.gz" \ && echo "7431f1179737fed6518ccf8187ad738c2f2e16feb75b7528e4e0bb7934d192cf Python-$PYTHON_VERSION.linux-aarch64-libffi3.2.tar.gz" | sha256sum -c - \ && tar -xzf "Python-$PYTHON_VERSION.linux-aarch64-libffi3.2.tar.gz" --strip-components=1 \ && rm -rf "Python-$PYTHON_VERSION.linux-aarch64-libffi3.2.tar.gz" \ && ldconfig \ && if [ ! -e /usr/local/bin/pip3 ]; then : \ && curl -SLO "https://raw.githubusercontent.com/pypa/get-pip/430ba37776ae2ad89f794c7a43b90dc23bac334c/get-pip.py" \ && echo "19dae841a150c86e2a09d475b5eb0602861f2a5b7761ec268049a662dbd2bd0c get-pip.py" | sha256sum -c - \ && python3 get-pip.py \ && rm get-pip.py \ ; fi \ && pip3 install --no-cache-dir --upgrade --force-reinstall pip=="$PYTHON_PIP_VERSION" setuptools=="$SETUPTOOLS_VERSION" \ && find /usr/local \ \( -type d -a -name test -o -name tests \) \ -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ -exec rm -rf '{}' + \ && cd / \ && rm -rf /usr/src/python ~/.cache # make some useful symlinks that are expected to exist RUN cd /usr/local/bin \ && ln -sf pip3 pip \ && { [ -e easy_install ] || ln -s easy_install-* easy_install; } \ && ln -sf idle3 idle \ && ln -sf pydoc3 pydoc \ && ln -sf python3 python \ && ln -sf python3-config python-config # set PYTHONPATH to point to dist-packages ENV PYTHONPATH /usr/lib/python3/dist-packages:$PYTHONPATH CMD ["echo","'No CMD command was set in Dockerfile! Details about CMD command could be found in Dockerfile Guide section in our Docs. Here's the link: https://balena.io/docs"] RUN curl -SLO "https://raw.githubusercontent.com/balena-io-library/base-images/8accad6af708fca7271c5c65f18a86782e19f877/scripts/assets/tests/test-stack@python.sh" \ && echo "Running test-stack@python" \ && chmod +x test-stack@python.sh \ && bash test-stack@python.sh \ && rm -rf test-stack@python.sh RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo 'Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): \nArchitecture: ARM v8 \nOS: Debian Stretch \nVariant: run variant \nDefault variable(s): UDEV=off \nThe following software stack is preinstalled: \nPython v3.8.12, Pip v21.3.1, Setuptools v60.5.4 \nExtra features: \n- Easy way to install packages with `install_packages <package-name>` command \n- Run anywhere with cross-build feature (for ARM only) \n- Keep the container idling with `balena-idle` command \n- Show base image details with `balena-info` command' > /.balena/messages/image-info RUN echo '#!/bin/sh.real\nbalena-info\nrm -f /bin/sh\ncp /bin/sh.real /bin/sh\n/bin/sh "$@"' > /bin/sh-shim \ && chmod +x /bin/sh-shim \ && cp /bin/sh /bin/sh.real \ && mv /bin/sh-shim /bin/sh
resin-io-library/base-images
balena-base-images/python/photon-nano/debian/stretch/3.8.12/run/Dockerfile
Dockerfile
apache-2.0
4,094
[ 30522, 1001, 8285, 6914, 16848, 5371, 2013, 28352, 8189, 29521, 1013, 26383, 1011, 28991, 1011, 2139, 15599, 1024, 7683, 1011, 2448, 1001, 6366, 2195, 10279, 1997, 2139, 15599, 18750, 2448, 26794, 1011, 2131, 24694, 1011, 1061, 18750, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
exports.view = function() { this.render(); }; exports.async = function() { this.render(); };
alibaba/plover
packages/plover/test/fixtures/core/app/modules/helper/index.js
JavaScript
apache-2.0
99
[ 30522, 14338, 1012, 3193, 1027, 3853, 1006, 1007, 1063, 2023, 1012, 17552, 1006, 1007, 1025, 1065, 1025, 14338, 1012, 2004, 6038, 2278, 1027, 3853, 1006, 1007, 1063, 2023, 1012, 17552, 1006, 1007, 1025, 1065, 1025, 102, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#-*- coding: utf8 -*- ''' Examples of advanced Python features: - metaclass - descriptor - generator/forloop ''' from __future__ import print_function import sys if sys.version_info > (3, ): # Python 3 exec(''' def exec_in(code, glob, loc=None): if isinstance(code, str): code = compile(code, '<string>', 'exec', dont_inherit=True) exec(code, glob, loc) ''') exec_in(''' def with_meta(cls): class Meta(metaclass=cls): pass return Meta ''', globals()) else: exec(''' def exec_in(code, glob, loc=None): if isinstance(code, str): code = compile(code, '', 'exec', dont_inherit=True) exec code in glob, loc ''') exec_in(''' def with_meta(cls): class Meta(object): __metaclass__ = cls pass return Meta ''', globals()) class AnimalMeta(type): species = 0 def __new__(cls, name, bases, attrs): if not name == 'Meta': cls.species += 1 print( 'First, metaclass.__new__ received (metaclass, name, bases, attrs)') print(cls, name, bases, attrs) return super(AnimalMeta, cls).__new__(cls, name, bases, attrs) def __init__(self, name, bases, attrs): if not name == 'Meta': print( 'Second, metaclass.__init__ received (self, name, bases, attrs)') print(self, name, bases, attrs) def __call__(self, *args, **kwargs): print("AnimalMeta.__call__") return super(AnimalMeta, self).__call__(*args, **kwargs) class Cat(with_meta(AnimalMeta)): name = 'cat' def __init__(self): print('Meow') kit = Cat()
dlutxx/memo
python/advanced.py
Python
mit
1,657
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 2620, 1011, 1008, 1011, 1005, 1005, 1005, 4973, 1997, 3935, 18750, 2838, 1024, 1011, 18804, 26266, 1011, 4078, 23235, 2953, 1011, 13103, 1013, 2005, 4135, 7361, 1005, 1005, 1005, 2013...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#import <UIKit/UIKit.h> #import "OLCVideoPlayer.h" FOUNDATION_EXPORT double OLCVideoPlayerVersionNumber; FOUNDATION_EXPORT const unsigned char OLCVideoPlayerVersionString[];
LakithaRav/OLCVideoPlayer
Example/Pods/Target Support Files/Pods-OLCVideoPlayer_Tests-OLCVideoPlayer/Pods-OLCVideoPlayer_Tests-OLCVideoPlayer-umbrella.h
C
mit
177
[ 30522, 1001, 12324, 1026, 21318, 23615, 1013, 21318, 23615, 1012, 1044, 1028, 1001, 12324, 1000, 19330, 2278, 17258, 8780, 13068, 2121, 1012, 1044, 1000, 3192, 1035, 9167, 3313, 19330, 2278, 17258, 8780, 13068, 2121, 27774, 19172, 5677, 1025,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
use azure_sdk_core::errors::AzureError; use azure_sdk_core::prelude::IfMatchCondition; use http::HeaderMap; #[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct DocumentAttributes { #[serde(rename = "_rid")] pub rid: String, #[serde(rename = "_ts")] pub ts: u64, #[serde(rename = "_self")] pub _self: String, #[serde(rename = "_etag")] pub etag: String, #[serde(rename = "_attachments")] pub attachments: String, } impl DocumentAttributes { pub fn rid(&self) -> &str { &self.rid } pub fn ts(&self) -> u64 { self.ts } pub fn _self(&self) -> &str { &self._self } pub fn etag(&self) -> &str { &self.etag } pub fn attachments(&self) -> &str { &self.attachments } pub fn set_rid<T>(&mut self, value: T) where T: Into<String>, { self.rid = value.into(); } pub fn set_ts(&mut self, value: u64) { self.ts = value; } pub fn set_self<T>(&mut self, value: T) where T: Into<String>, { self._self = value.into(); } pub fn set_etag<T>(&mut self, value: T) where T: Into<String>, { self.etag = value.into(); } pub fn set_attachments<T>(&mut self, value: T) where T: Into<String>, { self.attachments = value.into(); } } impl std::convert::TryFrom<(&HeaderMap, &[u8])> for DocumentAttributes { type Error = AzureError; fn try_from(value: (&HeaderMap, &[u8])) -> Result<Self, Self::Error> { let body = value.1; Ok(serde_json::from_slice(body)?) } } impl<'a> std::convert::From<&'a DocumentAttributes> for IfMatchCondition<'a> { fn from(document_attributes: &'a DocumentAttributes) -> Self { IfMatchCondition::Match(&document_attributes.etag) } } #[cfg(test)] mod tests { #[test] fn test_mutate() { use super::*; let mut a = DocumentAttributes { rid: "rid".to_owned(), ts: 100, _self: "_self".to_owned(), etag: "etag".to_owned(), attachments: "attachments".to_owned(), }; a.set_attachments("new_attachments".to_owned()); } }
MindFlavor/AzureSDKForRust
azure_sdk_cosmos/src/document_attributes.rs
Rust
apache-2.0
2,260
[ 30522, 2224, 24296, 1035, 17371, 2243, 1035, 4563, 1024, 1024, 10697, 1024, 1024, 24296, 2121, 29165, 1025, 2224, 24296, 1035, 17371, 2243, 1035, 4563, 1024, 1024, 19508, 1024, 1024, 2065, 18900, 2818, 8663, 20562, 1025, 2224, 8299, 1024, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="lang:clipboard.copy" content="Copy to clipboard"> <meta name="lang:clipboard.copied" content="Copied to clipboard"> <meta name="lang:search.language" content="en"> <meta name="lang:search.pipeline.stopwords" content="True"> <meta name="lang:search.pipeline.trimmer" content="True"> <meta name="lang:search.result.none" content="No matching documents"> <meta name="lang:search.result.one" content="1 matching document"> <meta name="lang:search.result.other" content="# matching documents"> <meta name="lang:search.tokenizer" content="[\s\-]+"> <link href="https://fonts.gstatic.com/" rel="preconnect" crossorigin> <link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700|Roboto:300,400,400i,700&display=fallback" rel="stylesheet"> <style> body, input { font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif } code, kbd, pre { font-family: "Roboto Mono", "Courier New", Courier, monospace } </style> <link rel="stylesheet" href="../../../../_static/stylesheets/application.css"/> <link rel="stylesheet" href="../../../../_static/stylesheets/application-palette.css"/> <link rel="stylesheet" href="../../../../_static/stylesheets/application-fixes.css"/> <link rel="stylesheet" href="../../../../_static/fonts/material-icons.css"/> <meta name="theme-color" content="#3f51b5"> <script src="../../../../_static/javascripts/modernizr.js"></script> <title>statsmodels.tsa.statespace.representation &#8212; statsmodels</title> <link rel="icon" type="image/png" sizes="32x32" href="../../../../_static/icons/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="../../../../_static/icons/favicon-16x16.png"> <link rel="manifest" href="../../../../_static/icons/site.webmanifest"> <link rel="mask-icon" href="../../../../_static/icons/safari-pinned-tab.svg" color="#919191"> <meta name="msapplication-TileColor" content="#2b5797"> <meta name="msapplication-config" content="../../../../_static/icons/browserconfig.xml"> <link rel="stylesheet" href="../../../../_static/stylesheets/examples.css"> <link rel="stylesheet" href="../../../../_static/stylesheets/deprecation.css"> <link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" /> <link rel="stylesheet" type="text/css" href="../../../../_static/material.css" /> <link rel="stylesheet" type="text/css" href="../../../../_static/graphviz.css" /> <link rel="stylesheet" type="text/css" href="../../../../_static/plot_directive.css" /> <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> <script src="../../../../_static/jquery.js"></script> <script src="../../../../_static/underscore.js"></script> <script src="../../../../_static/doctools.js"></script> <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> <link rel="shortcut icon" href="../../../../_static/favicon.ico"/> <link rel="author" title="About these documents" href="../../../../about.html" /> <link rel="index" title="Index" href="../../../../genindex.html" /> <link rel="search" title="Search" href="../../../../search.html" /> </head> <body dir=ltr data-md-color-primary=indigo data-md-color-accent=blue> <svg class="md-svg"> <defs data-children-count="0"> <svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg> </defs> </svg> <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer"> <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search"> <label class="md-overlay" data-md-component="overlay" for="__drawer"></label> <a href="#_modules/statsmodels/tsa/statespace/representation" tabindex="1" class="md-skip"> Skip to content </a> <header class="md-header" data-md-component="header"> <nav class="md-header-nav md-grid"> <div class="md-flex navheader"> <div class="md-flex__cell md-flex__cell--shrink"> <a href="../../../../index.html" title="statsmodels" class="md-header-nav__button md-logo"> <img src="../../../../_static/statsmodels-logo-v2-bw.svg" height="26" alt="statsmodels logo"> </a> </div> <div class="md-flex__cell md-flex__cell--shrink"> <label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label> </div> <div class="md-flex__cell md-flex__cell--stretch"> <div class="md-flex__ellipsis md-header-nav__title" data-md-component="title"> <span class="md-header-nav__topic">statsmodels v0.13.0</span> <span class="md-header-nav__topic"> statsmodels.tsa.statespace.representation </span> </div> </div> <div class="md-flex__cell md-flex__cell--shrink"> <label class="md-icon md-icon--search md-header-nav__button" for="__search"></label> <div class="md-search" data-md-component="search" role="dialog"> <label class="md-search__overlay" for="__search"></label> <div class="md-search__inner" role="search"> <form class="md-search__form" action="../../../../search.html" method="get" name="search"> <input type="text" class="md-search__input" name="q" placeholder="Search" autocapitalize="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active"> <label class="md-icon md-search__icon" for="__search"></label> <button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1"> &#xE5CD; </button> </form> <div class="md-search__output"> <div class="md-search__scrollwrap" data-md-scrollfix> <div class="md-search-result" data-md-component="result"> <div class="md-search-result__meta"> Type to start searching </div> <ol class="md-search-result__list"></ol> </div> </div> </div> </div> </div> </div> <div class="md-flex__cell md-flex__cell--shrink"> <div class="md-header-nav__source"> <a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github"> <div class="md-source__icon"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28"> <use xlink:href="#__github" width="24" height="24"></use> </svg> </div> <div class="md-source__repository"> statsmodels </div> </a> </div> </div> <script src="../../../../_static/javascripts/version_dropdown.js"></script> <script> var json_loc = "../../../../../versions-v2.json", target_loc = "../../../../../", text = "Versions"; $( document ).ready( add_version_dropdown(json_loc, target_loc, text)); </script> </div> </nav> </header> <div class="md-container"> <nav class="md-tabs" data-md-component="tabs"> <div class="md-tabs__inner md-grid"> <ul class="md-tabs__list"> <li class="md-tabs__item"><a href="../../../index.html" class="md-tabs__link">Module code</a></li> </ul> </div> </nav> <main class="md-main"> <div class="md-main__inner md-grid" data-md-component="container"> <div class="md-sidebar md-sidebar--primary" data-md-component="navigation"> <div class="md-sidebar__scrollwrap"> <div class="md-sidebar__inner"> <nav class="md-nav md-nav--primary" data-md-level="0"> <label class="md-nav__title md-nav__title--site" for="__drawer"> <a href="../../../../index.html" title="statsmodels" class="md-nav__button md-logo"> <img src="../../../../_static/statsmodels-logo-v2-bw.svg" alt=" logo" width="48" height="48"> </a> <a href="../../../../index.html" title="statsmodels">statsmodels v0.13.0</a> </label> <div class="md-nav__source"> <a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github"> <div class="md-source__icon"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28"> <use xlink:href="#__github" width="24" height="24"></use> </svg> </div> <div class="md-source__repository"> statsmodels </div> </a> </div> <ul class="md-nav__list"> <li class="md-nav__item"> <a href="../../../../install.html" class="md-nav__link">Installing statsmodels</a> </li> <li class="md-nav__item"> <a href="../../../../gettingstarted.html" class="md-nav__link">Getting started</a> </li> <li class="md-nav__item"> <a href="../../../../user-guide.html" class="md-nav__link">User Guide</a> </li> <li class="md-nav__item"> <a href="../../../../examples/index.html" class="md-nav__link">Examples</a> </li> <li class="md-nav__item"> <a href="../../../../api.html" class="md-nav__link">API Reference</a> </li> <li class="md-nav__item"> <a href="../../../../about.html" class="md-nav__link">About statsmodels</a> </li> <li class="md-nav__item"> <a href="../../../../dev/index.html" class="md-nav__link">Developer Page</a> </li> <li class="md-nav__item"> <a href="../../../../release/index.html" class="md-nav__link">Release Notes</a> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component="toc"> <div class="md-sidebar__scrollwrap"> <div class="md-sidebar__inner"> <nav class="md-nav md-nav--secondary"> <ul class="md-nav__list" data-md-scrollfix=""> <li id="searchbox" class="md-nav__item"></li> </ul> </nav> </div> </div> </div> <div class="md-content"> <article class="md-content__inner md-typeset" role="main"> <h1 id="modules-statsmodels-tsa-statespace-representation--page-root">Source code for statsmodels.tsa.statespace.representation</h1><div class="highlight"><pre> <span></span><span class="sd">"""</span> <span class="sd">State Space Representation</span> <span class="sd">Author: Chad Fulton</span> <span class="sd">License: Simplified-BSD</span> <span class="sd">"""</span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> <span class="kn">from</span> <span class="nn">.tools</span> <span class="kn">import</span> <span class="p">(</span> <span class="n">find_best_blas_type</span><span class="p">,</span> <span class="n">validate_matrix_shape</span><span class="p">,</span> <span class="n">validate_vector_shape</span> <span class="p">)</span> <span class="kn">from</span> <span class="nn">.initialization</span> <span class="kn">import</span> <span class="n">Initialization</span> <span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">tools</span> <span class="k">class</span> <span class="nc">OptionWrapper</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mask_attribute</span><span class="p">,</span> <span class="n">mask_value</span><span class="p">):</span> <span class="c1"># Name of the class-level bitmask attribute</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_attribute</span> <span class="o">=</span> <span class="n">mask_attribute</span> <span class="c1"># Value of this option</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_value</span> <span class="o">=</span> <span class="n">mask_value</span> <span class="k">def</span> <span class="fm">__get__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">objtype</span><span class="p">):</span> <span class="c1"># Return True / False based on whether the bit is set in the bitmask</span> <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="nb">getattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_attribute</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">&amp;</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_value</span><span class="p">)</span> <span class="k">def</span> <span class="fm">__set__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="n">mask_attribute_value</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_attribute</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="k">if</span> <span class="nb">bool</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> <span class="n">value</span> <span class="o">=</span> <span class="n">mask_attribute_value</span> <span class="o">|</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_value</span> <span class="k">else</span><span class="p">:</span> <span class="n">value</span> <span class="o">=</span> <span class="n">mask_attribute_value</span> <span class="o">&amp;</span> <span class="o">~</span><span class="bp">self</span><span class="o">.</span><span class="n">mask_value</span> <span class="nb">setattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask_attribute</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="k">class</span> <span class="nc">MatrixWrapper</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">attribute</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span> <span class="bp">self</span><span class="o">.</span><span class="n">attribute</span> <span class="o">=</span> <span class="n">attribute</span> <span class="bp">self</span><span class="o">.</span><span class="n">_attribute</span> <span class="o">=</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">attribute</span> <span class="k">def</span> <span class="fm">__get__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">objtype</span><span class="p">):</span> <span class="n">matrix</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_attribute</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="c1"># # Remove last dimension if the array is not actually time-varying</span> <span class="c1"># if matrix is not None and matrix.shape[-1] == 1:</span> <span class="c1"># return np.squeeze(matrix, -1)</span> <span class="k">return</span> <span class="n">matrix</span> <span class="k">def</span> <span class="fm">__set__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="n">value</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">)</span> <span class="n">shape</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">shapes</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">attribute</span><span class="p">]</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_matrix</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">shape</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_vector</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">shape</span><span class="p">)</span> <span class="nb">setattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_attribute</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="n">obj</span><span class="o">.</span><span class="n">shapes</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">attribute</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">shape</span> <span class="k">def</span> <span class="nf">_set_matrix</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">shape</span><span class="p">):</span> <span class="c1"># Expand 1-dimensional array if possible</span> <span class="k">if</span> <span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">value</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]):</span> <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="p">:]</span> <span class="c1"># Enforce that the matrix is appropriate size</span> <span class="n">validate_matrix_shape</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">obj</span><span class="o">.</span><span class="n">nobs</span> <span class="p">)</span> <span class="c1"># Expand time-invariant matrix</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="n">value</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">value</span><span class="p">[:,</span> <span class="p">:,</span> <span class="kc">None</span><span class="p">],</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">)</span> <span class="k">return</span> <span class="n">value</span> <span class="k">def</span> <span class="nf">_set_vector</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">shape</span><span class="p">):</span> <span class="c1"># Enforce that the vector has appropriate length</span> <span class="n">validate_vector_shape</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">obj</span><span class="o">.</span><span class="n">nobs</span> <span class="p">)</span> <span class="c1"># Expand the time-invariant vector</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="n">value</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">value</span><span class="p">[:,</span> <span class="kc">None</span><span class="p">],</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">)</span> <span class="k">return</span> <span class="n">value</span> <div class="viewcode-block" id="Representation"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.html#statsmodels.tsa.statespace.kalman_filter.Representation">[docs]</a><span class="k">class</span> <span class="nc">Representation</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> State space representation of a time series process</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> k_endog : {array_like, int}</span> <span class="sd"> The observed time-series process :math:`y` if array like or the</span> <span class="sd"> number of variables in the process if an integer.</span> <span class="sd"> k_states : int</span> <span class="sd"> The dimension of the unobserved state process.</span> <span class="sd"> k_posdef : int, optional</span> <span class="sd"> The dimension of a guaranteed positive definite covariance matrix</span> <span class="sd"> describing the shocks in the measurement equation. Must be less than</span> <span class="sd"> or equal to `k_states`. Default is `k_states`.</span> <span class="sd"> initial_variance : float, optional</span> <span class="sd"> Initial variance used when approximate diffuse initialization is</span> <span class="sd"> specified. Default is 1e6.</span> <span class="sd"> initialization : Initialization object or str, optional</span> <span class="sd"> Initialization method for the initial state. If a string, must be one</span> <span class="sd"> of {'diffuse', 'approximate_diffuse', 'stationary', 'known'}.</span> <span class="sd"> initial_state : array_like, optional</span> <span class="sd"> If `initialization='known'` is used, the mean of the initial state's</span> <span class="sd"> distribution.</span> <span class="sd"> initial_state_cov : array_like, optional</span> <span class="sd"> If `initialization='known'` is used, the covariance matrix of the</span> <span class="sd"> initial state's distribution.</span> <span class="sd"> nobs : int, optional</span> <span class="sd"> If an endogenous vector is not given (i.e. `k_endog` is an integer),</span> <span class="sd"> the number of observations can optionally be specified. If not</span> <span class="sd"> specified, they will be set to zero until data is bound to the model.</span> <span class="sd"> dtype : np.dtype, optional</span> <span class="sd"> If an endogenous vector is not given (i.e. `k_endog` is an integer),</span> <span class="sd"> the default datatype of the state space matrices can optionally be</span> <span class="sd"> specified. Default is `np.float64`.</span> <span class="sd"> design : array_like, optional</span> <span class="sd"> The design matrix, :math:`Z`. Default is set to zeros.</span> <span class="sd"> obs_intercept : array_like, optional</span> <span class="sd"> The intercept for the observation equation, :math:`d`. Default is set</span> <span class="sd"> to zeros.</span> <span class="sd"> obs_cov : array_like, optional</span> <span class="sd"> The covariance matrix for the observation equation :math:`H`. Default</span> <span class="sd"> is set to zeros.</span> <span class="sd"> transition : array_like, optional</span> <span class="sd"> The transition matrix, :math:`T`. Default is set to zeros.</span> <span class="sd"> state_intercept : array_like, optional</span> <span class="sd"> The intercept for the transition equation, :math:`c`. Default is set to</span> <span class="sd"> zeros.</span> <span class="sd"> selection : array_like, optional</span> <span class="sd"> The selection matrix, :math:`R`. Default is set to zeros.</span> <span class="sd"> state_cov : array_like, optional</span> <span class="sd"> The covariance matrix for the state equation :math:`Q`. Default is set</span> <span class="sd"> to zeros.</span> <span class="sd"> **kwargs</span> <span class="sd"> Additional keyword arguments. Not used directly. It is present to</span> <span class="sd"> improve compatibility with subclasses, so that they can use `**kwargs`</span> <span class="sd"> to specify any default state space matrices (e.g. `design`) without</span> <span class="sd"> having to clean out any other keyword arguments they might have been</span> <span class="sd"> passed.</span> <span class="sd"> Attributes</span> <span class="sd"> ----------</span> <span class="sd"> nobs : int</span> <span class="sd"> The number of observations.</span> <span class="sd"> k_endog : int</span> <span class="sd"> The dimension of the observation series.</span> <span class="sd"> k_states : int</span> <span class="sd"> The dimension of the unobserved state process.</span> <span class="sd"> k_posdef : int</span> <span class="sd"> The dimension of a guaranteed positive</span> <span class="sd"> definite covariance matrix describing</span> <span class="sd"> the shocks in the measurement equation.</span> <span class="sd"> shapes : dictionary of name:tuple</span> <span class="sd"> A dictionary recording the initial shapes</span> <span class="sd"> of each of the representation matrices as</span> <span class="sd"> tuples.</span> <span class="sd"> initialization : str</span> <span class="sd"> Kalman filter initialization method. Default is unset.</span> <span class="sd"> initial_variance : float</span> <span class="sd"> Initial variance for approximate diffuse</span> <span class="sd"> initialization. Default is 1e6.</span> <span class="sd"> Notes</span> <span class="sd"> -----</span> <span class="sd"> A general state space model is of the form</span> <span class="sd"> .. math::</span> <span class="sd"> y_t &amp; = Z_t \alpha_t + d_t + \varepsilon_t \\</span> <span class="sd"> \alpha_t &amp; = T_t \alpha_{t-1} + c_t + R_t \eta_t \\</span> <span class="sd"> where :math:`y_t` refers to the observation vector at time :math:`t`,</span> <span class="sd"> :math:`\alpha_t` refers to the (unobserved) state vector at time</span> <span class="sd"> :math:`t`, and where the irregular components are defined as</span> <span class="sd"> .. math::</span> <span class="sd"> \varepsilon_t \sim N(0, H_t) \\</span> <span class="sd"> \eta_t \sim N(0, Q_t) \\</span> <span class="sd"> The remaining variables (:math:`Z_t, d_t, H_t, T_t, c_t, R_t, Q_t`) in the</span> <span class="sd"> equations are matrices describing the process. Their variable names and</span> <span class="sd"> dimensions are as follows</span> <span class="sd"> Z : `design` :math:`(k\_endog \times k\_states \times nobs)`</span> <span class="sd"> d : `obs_intercept` :math:`(k\_endog \times nobs)`</span> <span class="sd"> H : `obs_cov` :math:`(k\_endog \times k\_endog \times nobs)`</span> <span class="sd"> T : `transition` :math:`(k\_states \times k\_states \times nobs)`</span> <span class="sd"> c : `state_intercept` :math:`(k\_states \times nobs)`</span> <span class="sd"> R : `selection` :math:`(k\_states \times k\_posdef \times nobs)`</span> <span class="sd"> Q : `state_cov` :math:`(k\_posdef \times k\_posdef \times nobs)`</span> <span class="sd"> In the case that one of the matrices is time-invariant (so that, for</span> <span class="sd"> example, :math:`Z_t = Z_{t+1} ~ \forall ~ t`), its last dimension may</span> <span class="sd"> be of size :math:`1` rather than size `nobs`.</span> <span class="sd"> References</span> <span class="sd"> ----------</span> <span class="sd"> .. [*] Durbin, James, and Siem Jan Koopman. 2012.</span> <span class="sd"> Time Series Analysis by State Space Methods: Second Edition.</span> <span class="sd"> Oxford University Press.</span> <span class="sd"> """</span> <span class="n">endog</span> <span class="o">=</span> <span class="kc">None</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) The observation vector, alias for `obs`.</span> <span class="sd"> """</span> <span class="n">design</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'design'</span><span class="p">,</span> <span class="s1">'design'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Design matrix: :math:`Z~(k\_endog \times k\_states \times nobs)`</span> <span class="sd"> """</span> <span class="n">obs_intercept</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'observation intercept'</span><span class="p">,</span> <span class="s1">'obs_intercept'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Observation intercept: :math:`d~(k\_endog \times nobs)`</span> <span class="sd"> """</span> <span class="n">obs_cov</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'observation covariance matrix'</span><span class="p">,</span> <span class="s1">'obs_cov'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Observation covariance matrix:</span> <span class="sd"> :math:`H~(k\_endog \times k\_endog \times nobs)`</span> <span class="sd"> """</span> <span class="n">transition</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'transition'</span><span class="p">,</span> <span class="s1">'transition'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Transition matrix:</span> <span class="sd"> :math:`T~(k\_states \times k\_states \times nobs)`</span> <span class="sd"> """</span> <span class="n">state_intercept</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'state intercept'</span><span class="p">,</span> <span class="s1">'state_intercept'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) State intercept: :math:`c~(k\_states \times nobs)`</span> <span class="sd"> """</span> <span class="n">selection</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'selection'</span><span class="p">,</span> <span class="s1">'selection'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Selection matrix:</span> <span class="sd"> :math:`R~(k\_states \times k\_posdef \times nobs)`</span> <span class="sd"> """</span> <span class="n">state_cov</span> <span class="o">=</span> <span class="n">MatrixWrapper</span><span class="p">(</span><span class="s1">'state covariance matrix'</span><span class="p">,</span> <span class="s1">'state_cov'</span><span class="p">)</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) State covariance matrix:</span> <span class="sd"> :math:`Q~(k\_posdef \times k\_posdef \times nobs)`</span> <span class="sd"> """</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k_endog</span><span class="p">,</span> <span class="n">k_states</span><span class="p">,</span> <span class="n">k_posdef</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">initial_variance</span><span class="o">=</span><span class="mf">1e6</span><span class="p">,</span> <span class="n">nobs</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">,</span> <span class="n">design</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">obs_intercept</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">obs_cov</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">transition</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">state_intercept</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">selection</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">state_cov</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">statespace_classes</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Check if k_endog is actually the endog array</span> <span class="n">endog</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">k_endog</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">k_endog</span> <span class="c1"># If so, assume that it is either column-ordered and in wide format</span> <span class="c1"># or row-ordered and in long format</span> <span class="k">if</span> <span class="p">(</span><span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'C_CONTIGUOUS'</span><span class="p">]</span> <span class="ow">and</span> <span class="p">(</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">nobs</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)):</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">endog</span><span class="o">.</span><span class="n">T</span> <span class="n">k_endog</span> <span class="o">=</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c1"># Endogenous array, dimensions, dtype</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span> <span class="o">=</span> <span class="n">k_endog</span> <span class="k">if</span> <span class="n">k_endog</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Number of endogenous variables in statespace'</span> <span class="s1">' model must be a positive number.'</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">=</span> <span class="n">nobs</span> <span class="c1"># Get dimensions from transition equation</span> <span class="k">if</span> <span class="n">k_states</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Number of states in statespace model must be a'</span> <span class="s1">' positive number.'</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span> <span class="o">=</span> <span class="n">k_states</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span> <span class="o">=</span> <span class="n">k_posdef</span> <span class="k">if</span> <span class="n">k_posdef</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">k_states</span> <span class="c1"># Make sure k_posdef &lt;= k_states</span> <span class="c1"># TODO: we could technically allow k_posdef &gt; k_states, but the Cython</span> <span class="c1"># code needs to be more thoroughly checked to avoid seg faults.</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Dimension of state innovation `k_posdef` cannot'</span> <span class="s1">' be larger than the dimension of the state.'</span><span class="p">)</span> <span class="c1"># Bind endog, if it was given</span> <span class="k">if</span> <span class="n">endog</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="c1"># Record the shapes of all of our matrices</span> <span class="c1"># Note: these are time-invariant shapes; in practice the last dimension</span> <span class="c1"># may also be `self.nobs` for any or all of these.</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span> <span class="o">=</span> <span class="p">{</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span><span class="p">),</span> <span class="s1">'design'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'obs_intercept'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'obs_cov'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'transition'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'state_intercept'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'selection'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="s1">'state_cov'</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">}</span> <span class="c1"># Representation matrices</span> <span class="c1"># These matrices are only used in the Python object as containers,</span> <span class="c1"># which will be copied to the appropriate _statespace object if a</span> <span class="c1"># filter is called.</span> <span class="n">scope</span> <span class="o">=</span> <span class="nb">locals</span><span class="p">()</span> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">shape</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="k">continue</span> <span class="c1"># Create the initial storage array for each matrix</span> <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">name</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">))</span> <span class="c1"># If we were given an initial value for the matrix, set it</span> <span class="c1"># (notice it is being set via the descriptor)</span> <span class="k">if</span> <span class="n">scope</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="p">[</span><span class="n">name</span><span class="p">])</span> <span class="c1"># Options</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_variance</span> <span class="o">=</span> <span class="n">initial_variance</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix_statespace_map</span> <span class="o">=</span> <span class="p">(</span><span class="n">statespace_classes</span> <span class="k">if</span> <span class="n">statespace_classes</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">tools</span><span class="o">.</span><span class="n">prefix_statespace_map</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> <span class="c1"># State-space initialization data</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'initialization'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="n">basic_inits</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'diffuse'</span><span class="p">,</span> <span class="s1">'approximate_diffuse'</span><span class="p">,</span> <span class="s1">'stationary'</span><span class="p">]</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="ow">in</span> <span class="n">basic_inits</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="p">)</span> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="o">==</span> <span class="s1">'known'</span><span class="p">:</span> <span class="k">if</span> <span class="s1">'constant'</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="n">constant</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'constant'</span><span class="p">]</span> <span class="k">elif</span> <span class="s1">'initial_state'</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="c1"># TODO deprecation warning</span> <span class="n">constant</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'initial_state'</span><span class="p">]</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Initial state must be provided when "known"'</span> <span class="s1">' is the specified initialization method.'</span><span class="p">)</span> <span class="k">if</span> <span class="s1">'stationary_cov'</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="n">stationary_cov</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'stationary_cov'</span><span class="p">]</span> <span class="k">elif</span> <span class="s1">'initial_state_cov'</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="c1"># TODO deprecation warning</span> <span class="n">stationary_cov</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'initial_state_cov'</span><span class="p">]</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Initial state covariance matrix must be'</span> <span class="s1">' provided when "known" is the specified'</span> <span class="s1">' initialization method.'</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="s1">'known'</span><span class="p">,</span> <span class="n">constant</span><span class="o">=</span><span class="n">constant</span><span class="p">,</span> <span class="n">stationary_cov</span><span class="o">=</span><span class="n">stationary_cov</span><span class="p">)</span> <span class="k">elif</span> <span class="p">(</span><span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="p">,</span> <span class="n">Initialization</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid state space initialization method."</span><span class="p">)</span> <span class="c1"># Matrix representations storage</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Setup the underlying statespace object storage</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># Caches</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time_invariant</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span> <span class="n">_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># If only a string is given then we must be getting an entire matrix</span> <span class="k">if</span> <span class="n">_type</span> <span class="ow">is</span> <span class="nb">str</span><span class="p">:</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'"</span><span class="si">%s</span><span class="s1">" is an invalid state space matrix name'</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span> <span class="n">matrix</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">key</span><span class="p">)</span> <span class="c1"># See note on time-varying arrays, below</span> <span class="k">if</span> <span class="n">matrix</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="k">return</span> <span class="n">matrix</span><span class="p">[(</span><span class="nb">slice</span><span class="p">(</span><span class="kc">None</span><span class="p">),)</span><span class="o">*</span><span class="p">(</span><span class="n">matrix</span><span class="o">.</span><span class="n">ndim</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="mi">0</span><span class="p">,)]</span> <span class="k">else</span><span class="p">:</span> <span class="k">return</span> <span class="n">matrix</span> <span class="c1"># Otherwise if we have a tuple, we want a slice of a matrix</span> <span class="k">elif</span> <span class="n">_type</span> <span class="ow">is</span> <span class="nb">tuple</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> <span class="n">slice_</span> <span class="o">=</span> <span class="n">key</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">key</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'"</span><span class="si">%s</span><span class="s1">" is an invalid state space matrix name'</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span> <span class="n">matrix</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">name</span><span class="p">)</span> <span class="c1"># Since the model can support time-varying arrays, but often we</span> <span class="c1"># will instead have time-invariant arrays, we want to allow setting</span> <span class="c1"># a matrix slice like mod['transition',0,:] even though technically</span> <span class="c1"># it should be mod['transition',0,:,0]. Thus if the array in</span> <span class="c1"># question is time-invariant but the last slice was excluded,</span> <span class="c1"># add it in as a zero.</span> <span class="k">if</span> <span class="n">matrix</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">slice_</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">matrix</span><span class="o">.</span><span class="n">ndim</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span> <span class="n">slice_</span> <span class="o">=</span> <span class="n">slice_</span> <span class="o">+</span> <span class="p">(</span><span class="mi">0</span><span class="p">,)</span> <span class="k">return</span> <span class="n">matrix</span><span class="p">[</span><span class="n">slice_</span><span class="p">]</span> <span class="c1"># Otherwise, we have only a single slice index, but it is not a string</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'First index must the name of a valid state space'</span> <span class="s1">' matrix.'</span><span class="p">)</span> <span class="k">def</span> <span class="fm">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="n">_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># If only a string is given then we must be setting an entire matrix</span> <span class="k">if</span> <span class="n">_type</span> <span class="ow">is</span> <span class="nb">str</span><span class="p">:</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'"</span><span class="si">%s</span><span class="s1">" is an invalid state space matrix name'</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span> <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="c1"># If it's a tuple (with a string as the first element) then we must be</span> <span class="c1"># setting a slice of a matrix</span> <span class="k">elif</span> <span class="n">_type</span> <span class="ow">is</span> <span class="nb">tuple</span><span class="p">:</span> <span class="n">name</span><span class="p">,</span> <span class="n">slice_</span> <span class="o">=</span> <span class="n">key</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">key</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'"</span><span class="si">%s</span><span class="s1">" is an invalid state space matrix name'</span> <span class="o">%</span> <span class="n">key</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1"># Change the dtype of the corresponding matrix</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">dtype</span> <span class="n">matrix</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">name</span><span class="p">)</span> <span class="n">valid_types</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'f'</span><span class="p">,</span> <span class="s1">'d'</span><span class="p">,</span> <span class="s1">'F'</span><span class="p">,</span> <span class="s1">'D'</span><span class="p">]</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">matrix</span><span class="o">.</span><span class="n">dtype</span> <span class="o">==</span> <span class="n">dtype</span> <span class="ow">and</span> <span class="n">dtype</span><span class="o">.</span><span class="n">char</span> <span class="ow">in</span> <span class="n">valid_types</span><span class="p">:</span> <span class="n">matrix</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">real</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="c1"># Since the model can support time-varying arrays, but often we</span> <span class="c1"># will instead have time-invariant arrays, we want to allow setting</span> <span class="c1"># a matrix slice like mod['transition',0,:] even though technically</span> <span class="c1"># it should be mod['transition',0,:,0]. Thus if the array in</span> <span class="c1"># question is time-invariant but the last slice was excluded,</span> <span class="c1"># add it in as a zero.</span> <span class="k">if</span> <span class="n">matrix</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">slice_</span><span class="p">)</span> <span class="o">==</span> <span class="n">matrix</span><span class="o">.</span><span class="n">ndim</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span> <span class="n">slice_</span> <span class="o">=</span> <span class="n">slice_</span> <span class="o">+</span> <span class="p">(</span><span class="mi">0</span><span class="p">,)</span> <span class="c1"># Set the new value</span> <span class="n">matrix</span><span class="p">[</span><span class="n">slice_</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">matrix</span><span class="p">)</span> <span class="c1"># Otherwise we got a single non-string key, (e.g. mod[:]), which is</span> <span class="c1"># invalid</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">IndexError</span><span class="p">(</span><span class="s1">'First index must the name of a valid state space'</span> <span class="s1">' matrix.'</span><span class="p">)</span> <span class="k">def</span> <span class="nf">_clone_kwargs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">endog</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Construct keyword arguments for cloning a state space model</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> endog : array_like</span> <span class="sd"> An observed time-series process :math:`y`.</span> <span class="sd"> **kwargs</span> <span class="sd"> Keyword arguments to pass to the new state space representation</span> <span class="sd"> model constructor. Those that are not specified are copied from</span> <span class="sd"> the specification of the current state space model.</span> <span class="sd"> """</span> <span class="c1"># We always need the base dimensions, but they cannot change from</span> <span class="c1"># the base model when cloning (the idea is: if these need to change,</span> <span class="c1"># need to make a new instance manually, since it's not really cloning).</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'nobs'</span><span class="p">]</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="n">kwargs</span><span class="p">[</span><span class="s1">'k_endog'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'k_states'</span><span class="p">,</span> <span class="s1">'k_posdef'</span><span class="p">]:</span> <span class="n">val</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span> <span class="ow">or</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span> <span class="k">if</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">!=</span> <span class="n">val</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Cannot change the dimension of </span><span class="si">%s</span><span class="s1"> when'</span> <span class="s1">' cloning.'</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span> <span class="c1"># Get defaults for time-invariant system matrices, if not otherwise</span> <span class="c1"># provided</span> <span class="c1"># Time-varying matrices must be replaced.</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="k">continue</span> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="n">mat</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'The `</span><span class="si">%s</span><span class="s1">` matrix is time-varying. Cloning'</span> <span class="s1">' this model requires specifying an'</span> <span class="s1">' updated matrix.'</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">mat</span> <span class="c1"># Default is to use the same initialization</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s1">'initialization'</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="p">)</span> <span class="k">return</span> <span class="n">kwargs</span> <div class="viewcode-block" id="Representation.clone"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.clone.html#statsmodels.tsa.statespace.kalman_filter.Representation.clone">[docs]</a> <span class="k">def</span> <span class="nf">clone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">endog</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Clone a state space representation while overriding some elements</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> endog : array_like</span> <span class="sd"> An observed time-series process :math:`y`.</span> <span class="sd"> **kwargs</span> <span class="sd"> Keyword arguments to pass to the new state space representation</span> <span class="sd"> model constructor. Those that are not specified are copied from</span> <span class="sd"> the specification of the current state space model.</span> <span class="sd"> Returns</span> <span class="sd"> -------</span> <span class="sd"> Representation</span> <span class="sd"> Notes</span> <span class="sd"> -----</span> <span class="sd"> If some system matrices are time-varying, then new time-varying</span> <span class="sd"> matrices *must* be provided.</span> <span class="sd"> """</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_clone_kwargs</span><span class="p">(</span><span class="n">endog</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="n">mod</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="n">mod</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="k">return</span> <span class="n">mod</span></div> <div class="viewcode-block" id="Representation.extend"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.extend.html#statsmodels.tsa.statespace.kalman_filter.Representation.extend">[docs]</a> <span class="k">def</span> <span class="nf">extend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">endog</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Extend the current state space model, or a specific (time) subset</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> endog : array_like</span> <span class="sd"> An observed time-series process :math:`y`.</span> <span class="sd"> start : int, optional</span> <span class="sd"> The first period of a time-varying state space model to include in</span> <span class="sd"> the new model. Has no effect if the state space model is</span> <span class="sd"> time-invariant. Default is the initial period.</span> <span class="sd"> end : int, optional</span> <span class="sd"> The last period of a time-varying state space model to include in</span> <span class="sd"> the new model. Has no effect if the state space model is</span> <span class="sd"> time-invariant. Default is the final period.</span> <span class="sd"> **kwargs</span> <span class="sd"> Keyword arguments to pass to the new state space representation</span> <span class="sd"> model constructor. Those that are not specified are copied from</span> <span class="sd"> the specification of the current state space model.</span> <span class="sd"> Returns</span> <span class="sd"> -------</span> <span class="sd"> Representation</span> <span class="sd"> Notes</span> <span class="sd"> -----</span> <span class="sd"> This method does not allow replacing a time-varying system matrix with</span> <span class="sd"> a time-invariant one (or vice-versa). If that is required, use `clone`.</span> <span class="sd"> """</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">atleast_1d</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="k">if</span> <span class="n">endog</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">endog</span><span class="p">[:,</span> <span class="n">np</span><span class="o">.</span><span class="n">newaxis</span><span class="p">]</span> <span class="n">nobs</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">start</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="n">end</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="k">if</span> <span class="n">start</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">+</span> <span class="n">start</span> <span class="k">if</span> <span class="n">end</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">+</span> <span class="n">end</span> <span class="k">if</span> <span class="n">start</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'The `start` argument of the extension within the'</span> <span class="s1">' base model cannot be after the end of the'</span> <span class="s1">' base model.'</span><span class="p">)</span> <span class="k">if</span> <span class="n">end</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'The `end` argument of the extension within the'</span> <span class="s1">' base model cannot be after the end of the'</span> <span class="s1">' base model.'</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="o">&gt;</span> <span class="n">end</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'The `start` argument of the extension within the'</span> <span class="s1">' base model cannot be after the `end` argument.'</span><span class="p">)</span> <span class="c1"># Note: if start == end or if end &lt; self.nobs, then we're just cloning</span> <span class="c1"># (no extension)</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">tools</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="p">[:,</span> <span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">endog</span><span class="p">])</span> <span class="c1"># Extend any time-varying arrays</span> <span class="n">error_ti</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'Model has time-invariant </span><span class="si">%s</span><span class="s1"> matrix, so cannot provide'</span> <span class="s1">' an extended matrix.'</span><span class="p">)</span> <span class="n">error_tv</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'Model has time-varying </span><span class="si">%s</span><span class="s1"> matrix, so an updated'</span> <span class="s1">' time-varying matrix for the extension period'</span> <span class="s1">' is required.'</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">shape</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="k">continue</span> <span class="n">mat</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> <span class="c1"># If we were *not* given an extended value for this matrix...</span> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span> <span class="c1"># If this is a time-varying matrix in the existing model</span> <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="c1"># If we have an extension period, then raise an error</span> <span class="c1"># because we should have been given an extended value</span> <span class="k">if</span> <span class="n">end</span> <span class="o">+</span> <span class="n">nobs</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_tv</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span> <span class="c1"># If we do not have an extension period, then set the new</span> <span class="c1"># time-varying matrix to be the portion of the existing</span> <span class="c1"># time-varying matrix that corresponds to the period of</span> <span class="c1"># interest</span> <span class="k">else</span><span class="p">:</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">mat</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span><span class="n">end</span> <span class="o">+</span> <span class="n">nobs</span><span class="p">]</span> <span class="k">elif</span> <span class="n">nobs</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Extension is being performed within-sample'</span> <span class="s1">' so cannot provide an extended matrix'</span><span class="p">)</span> <span class="c1"># If we were given an extended value for this matrix</span> <span class="k">else</span><span class="p">:</span> <span class="c1"># TODO: Need to add a check for ndim, and if the matrix has</span> <span class="c1"># one fewer dimensions than the existing matrix, add a new axis</span> <span class="c1"># If this is a time-invariant matrix in the existing model,</span> <span class="c1"># raise an error</span> <span class="k">if</span> <span class="n">mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_ti</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span> <span class="c1"># Otherwise, validate the shape of the given extended value</span> <span class="c1"># Note: we do not validate the number of observations here</span> <span class="c1"># (so we pass in updated_mat.shape[-1] as the nobs argument</span> <span class="c1"># in the validate_* calls); instead, we check below that we</span> <span class="c1"># at least `nobs` values were passed in and then only take the</span> <span class="c1"># first of them as required. This can be useful when e.g. the</span> <span class="c1"># end user knows the extension values up to some maximum</span> <span class="c1"># endpoint, but does not know what the calling methods may</span> <span class="c1"># specifically require.</span> <span class="n">updated_mat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">kwargs</span><span class="p">[</span><span class="n">name</span><span class="p">])</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="n">validate_vector_shape</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">updated_mat</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">updated_mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="k">else</span><span class="p">:</span> <span class="n">validate_matrix_shape</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">updated_mat</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span> <span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">updated_mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="k">if</span> <span class="n">updated_mat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">nobs</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_tv</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="n">updated_mat</span> <span class="o">=</span> <span class="n">updated_mat</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="p">:</span><span class="n">nobs</span><span class="p">]</span> <span class="c1"># Concatenate to get the new time-varying matrix</span> <span class="n">kwargs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">c_</span><span class="p">[</span><span class="n">mat</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">],</span> <span class="n">updated_mat</span><span class="p">]</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">clone</span><span class="p">(</span><span class="n">endog</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div> <div class="viewcode-block" id="Representation.diff_endog"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.diff_endog.html#statsmodels.tsa.statespace.kalman_filter.Representation.diff_endog">[docs]</a> <span class="k">def</span> <span class="nf">diff_endog</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">new_endog</span><span class="p">,</span> <span class="n">tolerance</span><span class="o">=</span><span class="mf">1e-10</span><span class="p">):</span> <span class="c1"># TODO: move this function to tools?</span> <span class="n">endog</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="o">.</span><span class="n">T</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">new_endog</span><span class="p">)</span> <span class="o">&lt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Given data (length </span><span class="si">%d</span><span class="s1">) is too short to diff'</span> <span class="s1">' against model data (length </span><span class="si">%d</span><span class="s1">).'</span> <span class="o">%</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">new_endog</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">)))</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">new_endog</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">):</span> <span class="n">nobs_append</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">new_endog</span><span class="p">)</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">c_</span><span class="p">[</span><span class="n">endog</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">new_endog</span><span class="p">[</span><span class="o">-</span><span class="n">nobs_append</span><span class="p">:]</span><span class="o">.</span><span class="n">T</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">]</span><span class="o">.</span><span class="n">T</span> <span class="n">new_nan</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">new_endog</span><span class="p">)</span> <span class="n">existing_nan</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">new_endog</span> <span class="o">-</span> <span class="n">endog</span><span class="p">)</span> <span class="n">diff</span><span class="p">[</span><span class="n">new_nan</span> <span class="o">^</span> <span class="n">existing_nan</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">inf</span> <span class="n">diff</span><span class="p">[</span><span class="n">new_nan</span> <span class="o">&amp;</span> <span class="n">existing_nan</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span> <span class="n">is_revision</span> <span class="o">=</span> <span class="p">(</span><span class="n">diff</span> <span class="o">&gt;</span> <span class="n">tolerance</span><span class="p">)</span> <span class="n">is_new</span> <span class="o">=</span> <span class="n">existing_nan</span> <span class="o">&amp;</span> <span class="o">~</span><span class="n">new_nan</span> <span class="n">is_revision</span><span class="p">[</span><span class="n">is_new</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> <span class="n">revision_ix</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">is_revision</span><span class="p">)))</span> <span class="n">new_ix</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">is_new</span><span class="p">)))</span> <span class="k">return</span> <span class="n">revision_ix</span><span class="p">,</span> <span class="n">new_ix</span></div> <span class="nd">@property</span> <span class="k">def</span> <span class="nf">prefix</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> (str) BLAS prefix of currently active representation matrices</span> <span class="sd"> """</span> <span class="n">arrays</span> <span class="o">=</span> <span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_design</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_obs_intercept</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_obs_cov</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_transition</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_state_intercept</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_selection</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_state_cov</span> <span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="n">arrays</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="p">,)</span> <span class="o">+</span> <span class="n">arrays</span> <span class="k">return</span> <span class="n">find_best_blas_type</span><span class="p">(</span><span class="n">arrays</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="nd">@property</span> <span class="k">def</span> <span class="nf">dtype</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> (dtype) Datatype of currently active representation matrices</span> <span class="sd"> """</span> <span class="k">return</span> <span class="n">tools</span><span class="o">.</span><span class="n">prefix_dtype_map</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span> <span class="nd">@property</span> <span class="k">def</span> <span class="nf">time_invariant</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> (bool) Whether or not currently active representation matrices are</span> <span class="sd"> time-invariant</span> <span class="sd"> """</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time_invariant</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">return</span> <span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_design</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_obs_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_obs_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_transition</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_state_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_selection</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_state_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time_invariant</span> <span class="nd">@property</span> <span class="k">def</span> <span class="nf">_statespace</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">:</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="k">return</span> <span class="kc">None</span> <span class="nd">@property</span> <span class="k">def</span> <span class="nf">obs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sa">r</span><span class="sd">"""</span> <span class="sd"> (array) Observation vector: :math:`y~(k\_endog \times nobs)`</span> <span class="sd"> """</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span> <div class="viewcode-block" id="Representation.bind"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.bind.html#statsmodels.tsa.statespace.kalman_filter.Representation.bind">[docs]</a> <span class="k">def</span> <span class="nf">bind</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">endog</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Bind data to the statespace representation</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> endog : ndarray</span> <span class="sd"> Endogenous data to bind to the model. Must be column-ordered</span> <span class="sd"> ndarray with shape (`k_endog`, `nobs`) or row-ordered ndarray with</span> <span class="sd"> shape (`nobs`, `k_endog`).</span> <span class="sd"> Notes</span> <span class="sd"> -----</span> <span class="sd"> The strict requirements arise because the underlying statespace and</span> <span class="sd"> Kalman filtering classes require Fortran-ordered arrays in the wide</span> <span class="sd"> format (shaped (`k_endog`, `nobs`)), and this structure is setup to</span> <span class="sd"> prevent copying arrays in memory.</span> <span class="sd"> By default, numpy arrays are row (C)-ordered and most time series are</span> <span class="sd"> represented in the long format (with time on the 0-th axis). In this</span> <span class="sd"> case, no copying or re-ordering needs to be performed, instead the</span> <span class="sd"> array can simply be transposed to get it in the right order and shape.</span> <span class="sd"> Although this class (Representation) has stringent `bind` requirements,</span> <span class="sd"> it is assumed that it will rarely be used directly.</span> <span class="sd"> """</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">endog</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid endogenous array; must be an ndarray."</span><span class="p">)</span> <span class="c1"># Make sure we have a 2-dimensional array</span> <span class="c1"># Note: reshaping a 1-dim array into a 2-dim array by changing the</span> <span class="c1"># shape tuple always results in a row (C)-ordered array, so it</span> <span class="c1"># must be shaped (nobs, k_endog)</span> <span class="k">if</span> <span class="n">endog</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="c1"># In the case of nobs x 0 arrays</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="p">(</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">1</span><span class="p">)</span> <span class="c1"># In the case of k_endog x 0 arrays</span> <span class="k">else</span><span class="p">:</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">endog</span><span class="o">.</span><span class="n">ndim</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid endogenous array provided; must be'</span> <span class="s1">' 2-dimensional.'</span><span class="p">)</span> <span class="c1"># Check for valid column-ordered arrays</span> <span class="k">if</span> <span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'F_CONTIGUOUS'</span><span class="p">]</span> <span class="ow">and</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">:</span> <span class="k">pass</span> <span class="c1"># Check for valid row-ordered arrays, and transpose them to be the</span> <span class="c1"># correct column-ordered array</span> <span class="k">elif</span> <span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'C_CONTIGUOUS'</span><span class="p">]</span> <span class="ow">and</span> <span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span><span class="p">:</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">endog</span><span class="o">.</span><span class="n">T</span> <span class="c1"># Invalid column-ordered arrays</span> <span class="k">elif</span> <span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'F_CONTIGUOUS'</span><span class="p">]:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid endogenous array; column-ordered'</span> <span class="s1">' arrays must have first axis shape of'</span> <span class="s1">' `k_endog`.'</span><span class="p">)</span> <span class="c1"># Invalid row-ordered arrays</span> <span class="k">elif</span> <span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'C_CONTIGUOUS'</span><span class="p">]:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid endogenous array; row-ordered'</span> <span class="s1">' arrays must have last axis shape of'</span> <span class="s1">' `k_endog`.'</span><span class="p">)</span> <span class="c1"># Non-contiguous arrays</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid endogenous array; must be ordered in'</span> <span class="s1">' contiguous memory.'</span><span class="p">)</span> <span class="c1"># We may still have a non-fortran contiguous array, so double-check</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">endog</span><span class="o">.</span><span class="n">flags</span><span class="p">[</span><span class="s1">'F_CONTIGUOUS'</span><span class="p">]:</span> <span class="n">endog</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asfortranarray</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="c1"># Set a flag for complex data</span> <span class="bp">self</span><span class="o">.</span><span class="n">_complex_endog</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">iscomplexobj</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span> <span class="c1"># Set the data</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span> <span class="o">=</span> <span class="n">endog</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="c1"># Reset shapes</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'shapes'</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">[</span><span class="s1">'obs'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span></div> <div class="viewcode-block" id="Representation.initialize"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.initialize.html#statsmodels.tsa.statespace.kalman_filter.Representation.initialize">[docs]</a> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">initialization</span><span class="p">,</span> <span class="n">approximate_diffuse_variance</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">constant</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">stationary_cov</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Create an Initialization object if necessary"""</span> <span class="k">if</span> <span class="n">initialization</span> <span class="o">==</span> <span class="s1">'known'</span><span class="p">:</span> <span class="n">initialization</span> <span class="o">=</span> <span class="n">Initialization</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="s1">'known'</span><span class="p">,</span> <span class="n">constant</span><span class="o">=</span><span class="n">constant</span><span class="p">,</span> <span class="n">stationary_cov</span><span class="o">=</span><span class="n">stationary_cov</span><span class="p">)</span> <span class="k">elif</span> <span class="n">initialization</span> <span class="o">==</span> <span class="s1">'approximate_diffuse'</span><span class="p">:</span> <span class="k">if</span> <span class="n">approximate_diffuse_variance</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">approximate_diffuse_variance</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_variance</span> <span class="n">initialization</span> <span class="o">=</span> <span class="n">Initialization</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="s1">'approximate_diffuse'</span><span class="p">,</span> <span class="n">approximate_diffuse_variance</span><span class="o">=</span><span class="n">approximate_diffuse_variance</span><span class="p">)</span> <span class="k">elif</span> <span class="n">initialization</span> <span class="o">==</span> <span class="s1">'stationary'</span><span class="p">:</span> <span class="n">initialization</span> <span class="o">=</span> <span class="n">Initialization</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="s1">'stationary'</span><span class="p">)</span> <span class="k">elif</span> <span class="n">initialization</span> <span class="o">==</span> <span class="s1">'diffuse'</span><span class="p">:</span> <span class="n">initialization</span> <span class="o">=</span> <span class="n">Initialization</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="s1">'diffuse'</span><span class="p">)</span> <span class="c1"># We must have an initialization object at this point</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">initialization</span><span class="p">,</span> <span class="n">Initialization</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid state space initialization method."</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="o">=</span> <span class="n">initialization</span></div> <div class="viewcode-block" id="Representation.initialize_known"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.initialize_known.html#statsmodels.tsa.statespace.kalman_filter.Representation.initialize_known">[docs]</a> <span class="k">def</span> <span class="nf">initialize_known</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">constant</span><span class="p">,</span> <span class="n">stationary_cov</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Initialize the statespace model with known distribution for initial</span> <span class="sd"> state.</span> <span class="sd"> These values are assumed to be known with certainty or else</span> <span class="sd"> filled with parameters during, for example, maximum likelihood</span> <span class="sd"> estimation.</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> constant : array_like</span> <span class="sd"> Known mean of the initial state vector.</span> <span class="sd"> stationary_cov : array_like</span> <span class="sd"> Known covariance matrix of the initial state vector.</span> <span class="sd"> """</span> <span class="n">constant</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">constant</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">)</span> <span class="n">stationary_cov</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">stationary_cov</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s2">"F"</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">constant</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid dimensions for constant state vector.'</span> <span class="s1">' Requires shape (</span><span class="si">%d</span><span class="s1">,), got </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">constant</span><span class="o">.</span><span class="n">shape</span><span class="p">)))</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">stationary_cov</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid dimensions for stationary covariance'</span> <span class="s1">' matrix. Requires shape (</span><span class="si">%d</span><span class="s1">,</span><span class="si">%d</span><span class="s1">), got </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">stationary_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">)))</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="s1">'known'</span><span class="p">,</span> <span class="n">constant</span><span class="o">=</span><span class="n">constant</span><span class="p">,</span> <span class="n">stationary_cov</span><span class="o">=</span><span class="n">stationary_cov</span><span class="p">)</span></div> <div class="viewcode-block" id="Representation.initialize_approximate_diffuse"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.initialize_approximate_diffuse.html#statsmodels.tsa.statespace.kalman_filter.Representation.initialize_approximate_diffuse">[docs]</a> <span class="k">def</span> <span class="nf">initialize_approximate_diffuse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">variance</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Initialize the statespace model with approximate diffuse values.</span> <span class="sd"> Rather than following the exact diffuse treatment (which is developed</span> <span class="sd"> for the case that the variance becomes infinitely large), this assigns</span> <span class="sd"> an arbitrary large number for the variance.</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> variance : float, optional</span> <span class="sd"> The variance for approximating diffuse initial conditions. Default</span> <span class="sd"> is 1e6.</span> <span class="sd"> """</span> <span class="k">if</span> <span class="n">variance</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">variance</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_variance</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="s1">'approximate_diffuse'</span><span class="p">,</span> <span class="n">approximate_diffuse_variance</span><span class="o">=</span><span class="n">variance</span><span class="p">)</span></div> <div class="viewcode-block" id="Representation.initialize_stationary"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.initialize_stationary.html#statsmodels.tsa.statespace.kalman_filter.Representation.initialize_stationary">[docs]</a> <span class="k">def</span> <span class="nf">initialize_stationary</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Initialize the statespace model as stationary.</span> <span class="sd"> """</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="s1">'stationary'</span><span class="p">)</span></div> <div class="viewcode-block" id="Representation.initialize_diffuse"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.Representation.initialize_diffuse.html#statsmodels.tsa.statespace.kalman_filter.Representation.initialize_diffuse">[docs]</a> <span class="k">def</span> <span class="nf">initialize_diffuse</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Initialize the statespace model as stationary.</span> <span class="sd"> """</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="s1">'diffuse'</span><span class="p">)</span></div> <span class="k">def</span> <span class="nf">_initialize_representation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">tools</span><span class="o">.</span><span class="n">prefix_dtype_map</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="c1"># If the dtype-specific representation matrices do not exist, create</span> <span class="c1"># them</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">:</span> <span class="c1"># Copy the statespace representation matrices</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">for</span> <span class="n">matrix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="k">if</span> <span class="n">matrix</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="n">matrix</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">obs</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="c1"># Note: this always makes a copy</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="n">matrix</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">matrix</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="p">)</span> <span class="c1"># If they do exist, update them</span> <span class="k">else</span><span class="p">:</span> <span class="k">for</span> <span class="n">matrix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="n">existing</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="n">matrix</span><span class="p">]</span> <span class="k">if</span> <span class="n">matrix</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="c1"># existing[:] = self.obs.astype(dtype)</span> <span class="k">pass</span> <span class="k">else</span><span class="p">:</span> <span class="n">new</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">'_'</span> <span class="o">+</span> <span class="n">matrix</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="k">if</span> <span class="n">existing</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="n">new</span><span class="o">.</span><span class="n">shape</span><span class="p">:</span> <span class="n">existing</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">new</span><span class="p">[:]</span> <span class="k">else</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="n">matrix</span><span class="p">]</span> <span class="o">=</span> <span class="n">new</span> <span class="c1"># Determine if we need to (re-)create the _statespace models</span> <span class="c1"># (if time-varying matrices changed)</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">:</span> <span class="n">ss</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="n">create</span> <span class="o">=</span> <span class="p">(</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">obs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">design</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">design</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">obs_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">obs_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">obs_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">obs_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">transition</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">transition</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="p">(</span><span class="n">ss</span><span class="o">.</span><span class="n">state_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">state_intercept</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">selection</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">selection</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">ss</span><span class="o">.</span><span class="n">state_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">state_cov</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="n">create</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># (re-)create if necessary</span> <span class="k">if</span> <span class="n">create</span><span class="p">:</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">:</span> <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="c1"># Setup the base statespace object</span> <span class="bp">cls</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix_statespace_map</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'obs'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'design'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'obs_intercept'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'obs_cov'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'transition'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'state_intercept'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'selection'</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_representations</span><span class="p">[</span><span class="n">prefix</span><span class="p">][</span><span class="s1">'state_cov'</span><span class="p">]</span> <span class="p">)</span> <span class="k">return</span> <span class="n">prefix</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">create</span> <span class="k">def</span> <span class="nf">_initialize_state</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">complex_step</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="c1"># TODO once the transition to using the Initialization objects is</span> <span class="c1"># complete, this should be moved entirely to the _{{prefix}}Statespace</span> <span class="c1"># object.</span> <span class="k">if</span> <span class="n">prefix</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="c1"># (Re-)initialize the statespace model</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="p">,</span> <span class="n">Initialization</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="o">.</span><span class="n">initialized</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">'Initialization is incomplete.'</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">initialization</span><span class="p">,</span> <span class="n">complex_step</span><span class="o">=</span><span class="n">complex_step</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">'Statespace model not initialized.'</span><span class="p">)</span></div> <div class="viewcode-block" id="FrozenRepresentation"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.FrozenRepresentation.html#statsmodels.tsa.statespace.kalman_filter.FrozenRepresentation">[docs]</a><span class="k">class</span> <span class="nc">FrozenRepresentation</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Frozen Statespace Model</span> <span class="sd"> Takes a snapshot of a Statespace model.</span> <span class="sd"> Parameters</span> <span class="sd"> ----------</span> <span class="sd"> model : Representation</span> <span class="sd"> A Statespace representation</span> <span class="sd"> Attributes</span> <span class="sd"> ----------</span> <span class="sd"> nobs : int</span> <span class="sd"> Number of observations.</span> <span class="sd"> k_endog : int</span> <span class="sd"> The dimension of the observation series.</span> <span class="sd"> k_states : int</span> <span class="sd"> The dimension of the unobserved state process.</span> <span class="sd"> k_posdef : int</span> <span class="sd"> The dimension of a guaranteed positive definite</span> <span class="sd"> covariance matrix describing the shocks in the</span> <span class="sd"> measurement equation.</span> <span class="sd"> dtype : dtype</span> <span class="sd"> Datatype of representation matrices</span> <span class="sd"> prefix : str</span> <span class="sd"> BLAS prefix of representation matrices</span> <span class="sd"> shapes : dictionary of name:tuple</span> <span class="sd"> A dictionary recording the shapes of each of</span> <span class="sd"> the representation matrices as tuples.</span> <span class="sd"> endog : ndarray</span> <span class="sd"> The observation vector.</span> <span class="sd"> design : ndarray</span> <span class="sd"> The design matrix, :math:`Z`.</span> <span class="sd"> obs_intercept : ndarray</span> <span class="sd"> The intercept for the observation equation, :math:`d`.</span> <span class="sd"> obs_cov : ndarray</span> <span class="sd"> The covariance matrix for the observation equation :math:`H`.</span> <span class="sd"> transition : ndarray</span> <span class="sd"> The transition matrix, :math:`T`.</span> <span class="sd"> state_intercept : ndarray</span> <span class="sd"> The intercept for the transition equation, :math:`c`.</span> <span class="sd"> selection : ndarray</span> <span class="sd"> The selection matrix, :math:`R`.</span> <span class="sd"> state_cov : ndarray</span> <span class="sd"> The covariance matrix for the state equation :math:`Q`.</span> <span class="sd"> missing : array of bool</span> <span class="sd"> An array of the same size as `endog`, filled</span> <span class="sd"> with boolean values that are True if the</span> <span class="sd"> corresponding entry in `endog` is NaN and False</span> <span class="sd"> otherwise.</span> <span class="sd"> nmissing : array of int</span> <span class="sd"> An array of size `nobs`, where the ith entry</span> <span class="sd"> is the number (between 0 and `k_endog`) of NaNs in</span> <span class="sd"> the ith row of the `endog` array.</span> <span class="sd"> time_invariant : bool</span> <span class="sd"> Whether or not the representation matrices are time-invariant</span> <span class="sd"> initialization : Initialization object</span> <span class="sd"> Kalman filter initialization method.</span> <span class="sd"> initial_state : array_like</span> <span class="sd"> The state vector used to initialize the Kalamn filter.</span> <span class="sd"> initial_state_cov : array_like</span> <span class="sd"> The state covariance matrix used to initialize the Kalamn filter.</span> <span class="sd"> """</span> <span class="n">_model_attributes</span> <span class="o">=</span> <span class="p">[</span> <span class="s1">'model'</span><span class="p">,</span> <span class="s1">'prefix'</span><span class="p">,</span> <span class="s1">'dtype'</span><span class="p">,</span> <span class="s1">'nobs'</span><span class="p">,</span> <span class="s1">'k_endog'</span><span class="p">,</span> <span class="s1">'k_states'</span><span class="p">,</span> <span class="s1">'k_posdef'</span><span class="p">,</span> <span class="s1">'time_invariant'</span><span class="p">,</span> <span class="s1">'endog'</span><span class="p">,</span> <span class="s1">'design'</span><span class="p">,</span> <span class="s1">'obs_intercept'</span><span class="p">,</span> <span class="s1">'obs_cov'</span><span class="p">,</span> <span class="s1">'transition'</span><span class="p">,</span> <span class="s1">'state_intercept'</span><span class="p">,</span> <span class="s1">'selection'</span><span class="p">,</span> <span class="s1">'state_cov'</span><span class="p">,</span> <span class="s1">'missing'</span><span class="p">,</span> <span class="s1">'nmissing'</span><span class="p">,</span> <span class="s1">'shapes'</span><span class="p">,</span> <span class="s1">'initialization'</span><span class="p">,</span> <span class="s1">'initial_state'</span><span class="p">,</span> <span class="s1">'initial_state_cov'</span><span class="p">,</span> <span class="s1">'initial_variance'</span> <span class="p">]</span> <span class="n">_attributes</span> <span class="o">=</span> <span class="n">_model_attributes</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">model</span><span class="p">):</span> <span class="c1"># Initialize all attributes to None</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_attributes</span><span class="p">:</span> <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="c1"># Update the representation attributes</span> <span class="bp">self</span><span class="o">.</span><span class="n">update_representation</span><span class="p">(</span><span class="n">model</span><span class="p">)</span> <div class="viewcode-block" id="FrozenRepresentation.update_representation"><a class="viewcode-back" href="../../../../generated/statsmodels.tsa.statespace.representation.FrozenRepresentation.update_representation.html#statsmodels.tsa.statespace.kalman_filter.FrozenRepresentation.update_representation">[docs]</a> <span class="k">def</span> <span class="nf">update_representation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">model</span><span class="p">):</span> <span class="sd">"""Update model Representation"""</span> <span class="c1"># Model</span> <span class="bp">self</span><span class="o">.</span><span class="n">model</span> <span class="o">=</span> <span class="n">model</span> <span class="c1"># Data type</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">prefix</span> <span class="bp">self</span><span class="o">.</span><span class="n">dtype</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">dtype</span> <span class="c1"># Copy the model dimensions</span> <span class="bp">self</span><span class="o">.</span><span class="n">nobs</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">nobs</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_endog</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">k_endog</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_states</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">k_states</span> <span class="bp">self</span><span class="o">.</span><span class="n">k_posdef</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">k_posdef</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_invariant</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">time_invariant</span> <span class="c1"># Save the state space representation at the time</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">endog</span> <span class="bp">self</span><span class="o">.</span><span class="n">design</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_design</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">obs_intercept</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_obs_intercept</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">obs_cov</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_obs_cov</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">transition</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_transition</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">state_intercept</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_state_intercept</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">selection</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_selection</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">state_cov</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">_state_cov</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">missing</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">missing</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">nmissing</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">nmissing</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="c1"># Save the final shapes of the matrices</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">shapes</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s1">'obs'</span><span class="p">:</span> <span class="k">continue</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span> <span class="bp">self</span><span class="o">.</span><span class="n">shapes</span><span class="p">[</span><span class="s1">'obs'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">endog</span><span class="o">.</span><span class="n">shape</span> <span class="c1"># Save the state space initialization</span> <span class="bp">self</span><span class="o">.</span><span class="n">initialization</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">initialization</span> <span class="k">if</span> <span class="n">model</span><span class="o">.</span><span class="n">initialization</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="n">model</span><span class="o">.</span><span class="n">_initialize_state</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_state</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span> <span class="n">model</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">initial_state</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_state_cov</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span> <span class="n">model</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">initial_state_cov</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">initial_diffuse_state_cov</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span> <span class="n">model</span><span class="o">.</span><span class="n">_statespaces</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">prefix</span><span class="p">]</span><span class="o">.</span><span class="n">initial_diffuse_state_cov</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span></div></div> </pre></div> </article> </div> </div> </main> </div> <footer class="md-footer"> <div class="md-footer-nav"> <nav class="md-footer-nav__inner md-grid"> </a> </nav> </div> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-footer-copyright"> <div class="md-footer-copyright__highlight"> &#169; Copyright 2009-2019, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers. </div> Last updated on Oct 06, 2021. <br/> Created using <a href="http://www.sphinx-doc.org/">Sphinx</a> 4.0.3. and <a href="https://github.com/bashtage/sphinx-material/">Material for Sphinx</a> </div> </div> </div> </footer> <script src="../../../../_static/javascripts/application.js"></script> <script>app.initialize({version: "1.0.4", url: {base: ".."}})</script> </body> </html>
statsmodels/statsmodels.github.io
v0.13.0/_modules/statsmodels/tsa/statespace/representation.html
HTML
bsd-3-clause
160,191
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 18804, 2171, 1027, 1000, 3193, 6442, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title> <meta name="author" content="{{ site.author.name }}" /> {% if page.subtitle %} <meta name="description" content="{{ page.subtitle }}"> {% endif %} <link rel="alternate" type="application/rss+xml" title="{{ site.title }} - {{ site.description }}" href="{{ site.baseurl }}/feed.xml" /> {% if layout.common-ext-css %} {% for css in layout.common-ext-css %} <link rel="stylesheet" href="{{ css }}" /> {% endfor %} {% endif %} {% if layout.common-css %} {% for css in layout.common-css %} <link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" /> {% endfor %} {% endif %} {% if layout.common-googlefonts %} {% for font in layout.common-googlefonts %} <link rel="stylesheet" href="//fonts.googleapis.com/css?family={{ font }}" /> {% endfor %} {% endif %} {% if page.ext-css %} {% for css in page.ext-css %} <link rel="stylesheet" href="{{ css }}" /> {% endfor %} {% endif %} {% if page.css %} {% for css in page.css %} <link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" /> {% endfor %} {% endif %} {% if page.googlefonts %} {% for font in page.googlefonts %} <link rel="stylesheet" href="//fonts.googleapis.com/css?family={{ font }}" /> {% endfor %} {% endif %} <!-- Facebook OpenGraph tags --> <meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" /> <meta property="og:type" content="website" /> {% if page.id %} <meta property="og:url" content="{{ site.url }}{{ page.url }}/" /> {% else %} <meta property="og:url" content="{{ site.url }}{{ page.url | remove: '/index.html' | remove: '.html' }}" /> {% endif %} {% if page.fb-img %} <meta property="og:image" content="{{ page.fb-img }}" /> {% elsif site.avatar %} <meta property="og:image" content="{{ site.url }}{{ site.avatar }}" /> {% else %} <meta property="og:image" content="" /> {% endif %} </head>
lachlanhurst/observedearth-web
_includes/head.html
HTML
mit
2,326
[ 30522, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 1060, 1011, 25423, 1011, 11892, 1000, 4180, 1027, 1000, 29464, 1027, 3341, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*---------------------------------------------------------------------------*\ ## #### ###### | ## ## ## | Copyright: ICE Stroemungsfoschungs GmbH ## ## #### | ## ## ## | http://www.ice-sf.at ## #### ###### | ------------------------------------------------------------------------------- ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is based on OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Contributors/Copyright: 2012-2013 Bernhard F.W. Gschaider <bgschaid@ice-sf.at> SWAK Revision: $Id$ \*---------------------------------------------------------------------------*/ #include "swakRadiationModelPluginFunction.H" #include "FieldValueExpressionDriver.H" #include "HashPtrTable.H" #include "swakThermoTypes.H" #include "addToRunTimeSelectionTable.H" namespace Foam { defineTypeNameAndDebug(swakRadiationModelPluginFunction,0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // swakRadiationModelPluginFunction::swakRadiationModelPluginFunction( const FieldValueExpressionDriver &parentDriver, const word &name, const word &returnValueType, const string &spec ): FieldValuePluginFunction( parentDriver, name, returnValueType, spec ) { } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const radiation::radiationModel &swakRadiationModelPluginFunction::radiationInternal( const fvMesh &reg ) { static HashPtrTable<radiation::radiationModel> radiation_; if(reg.foundObject<radiation::radiationModel>("radiationProperties")) { if(debug) { Info << "swakRadiationModelPluginFunction::radiationInternal: " << "already in memory" << endl; } // Somebody else already registered this return reg.lookupObject<radiation::radiationModel>("radiationProperties"); } if(!radiation_.found(reg.name())) { if(debug) { Info << "swakRadiationModelPluginFunction::radiationInternal: " << "not yet in memory for " << reg.name() << endl; } // Create it ourself because nobody registered it radiation_.set( reg.name(), radiation::radiationModel::New( reg.lookupObject<volScalarField>("T") ).ptr() ); Info << "Created radiation model. Calculating to get values ..." << endl; radiation_[reg.name()]->correct(); } return *(radiation_[reg.name()]); } const radiation::radiationModel &swakRadiationModelPluginFunction::radiation() { return radiationInternal(mesh()); } // * * * * * * * * * * * * * * * Concrete implementations * * * * * * * * * // #define concreteRadiationFunction(funcName,resultType) \ class swakRadiationModelPluginFunction_ ## funcName \ : public swakRadiationModelPluginFunction \ { \ public: \ TypeName("swakRadiationModelPluginFunction_" #funcName); \ swakRadiationModelPluginFunction_ ## funcName ( \ const FieldValueExpressionDriver &parentDriver, \ const word &name \ ): swakRadiationModelPluginFunction( \ parentDriver, \ name, \ #resultType \ ) {} \ void doEvaluation() { \ result().setObjectResult( \ autoPtr<resultType>( \ new resultType( \ radiation().funcName() \ ) \ ) \ ); \ } \ }; \ defineTypeNameAndDebug(swakRadiationModelPluginFunction_ ## funcName,0); \ addNamedToRunTimeSelectionTable(FieldValuePluginFunction,swakRadiationModelPluginFunction_ ## funcName,name,radiation_ ## funcName); concreteRadiationFunction(Rp,volScalarField); class swakRadiationModelPluginFunction_Ru : public swakRadiationModelPluginFunction { public: TypeName("swakRadiationModelPluginFunction_Ru"); swakRadiationModelPluginFunction_Ru ( const FieldValueExpressionDriver &parentDriver, const word &name ): swakRadiationModelPluginFunction( parentDriver, name, "volScalarField" ) {} void doEvaluation() { const DimensionedField<scalar,volMesh> &ruRad=radiation().Ru(); autoPtr<volScalarField> val( new volScalarField( IOobject( "radiationRu", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh(), dimensionedScalar("Ru",ruRad.dimensions(),0), "zeroGradient" ) ); val->dimensionedInternalField()=ruRad; result().setObjectResult( val ); } }; defineTypeNameAndDebug(swakRadiationModelPluginFunction_Ru,0); addNamedToRunTimeSelectionTable(FieldValuePluginFunction,swakRadiationModelPluginFunction_Ru,name,radiation_Ru); class swakRadiationModelPluginFunction_radSource : public swakRadiationModelPluginFunction { public: TypeName("swakRadiationModelPluginFunction_radSource"); swakRadiationModelPluginFunction_radSource ( const FieldValueExpressionDriver &parentDriver, const word &name ): swakRadiationModelPluginFunction( parentDriver, name, "volScalarField" ) {} void doEvaluation() { const volScalarField T4( pow4( mesh().lookupObject<volScalarField>("T") ) ); autoPtr<volScalarField> val( new volScalarField( IOobject ( "radSource", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), -T4*radiation().Rp(), "zeroGradient" ) ); val().internalField()+=radiation().Ru(); val().correctBoundaryConditions(); result().setObjectResult( val ); } }; defineTypeNameAndDebug(swakRadiationModelPluginFunction_radSource,0); addNamedToRunTimeSelectionTable(FieldValuePluginFunction,swakRadiationModelPluginFunction_radSource,name,radiation_radSource); } // namespace // ************************************************************************* //
aliozel/swak4Foam
Libraries/functionPlugins/swakRadiationModelFunctionPlugin/swakRadiationModelPluginFunction.C
C++
gpl-2.0
8,380
[ 30522, 1013, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
:: Execute a Ruby command with the current version @ setlocal EnableDelayedExpansion @ call "%~dp0common_vars.cmd" @ set PARAMS=%* :: If we are executing a Ruby script, search for the version inside the directory :: of this script instead of searching in the current directory @ if "%~1" == "ruby" ( set PARAMS= set SkipCount=1 for %%i in (%*) do @( if !SkipCount! leq 0 ( set PARAMS=!PARAMS! %%i ) else ( set /a SkipCount-=1 ) ) for %%i in (%PARAMS%) do @( set ARG=%%i if NOT "!ARG:~0,1!" == "-" ( if exist "!ARG!" ( for %%F in ("!ARG!") do @ set RBENV_SEARCH_DIR=%%~dpF break ) ) ) ) :: Retrieve current Ruby version @ for /f "usebackq tokens=*" %%i in (`%RBENV_ROOT%\libexec\rbenv_version.cmd --bare`) do @ set RUBY_VERSION=%%i @ if not defined RUBY_VERSION goto RubyVersionNotFound :: Compute path of current RUBY_VERSION @ set RUBY_PATH=%RBENV_VERSIONS%\%RUBY_VERSION% @ if not exist "%RUBY_PATH%" goto RubyVersionNotManaged :: Check if we called a script and if it exists in the current Ruby @ if not "%~1" == "ruby" ( if exist "%RBENV_SHIMS%\%~n1.cmd" ( if not exist "%RUBY_PATH%\bin\%~n1" goto ScriptNotInThisRubyVersion ) ) :: Compute how to call Ruby @ if "%RUBY_VERSION:~0,5%" == "jruby" ( if "%~1" == "" ( set COMMAND=jruby ) else if "%~1" == "jruby" ( set COMMAND=%PARAMS% ) else if exist "%RUBY_PATH%\bin\%~n1" ( set COMMAND=jruby -S %PARAMS% ) else ( set COMMAND=jruby %PARAMS% ) ) else ( if "%~1" == "" ( set COMMAND=ruby %PARAMS% ) else if exist "%RUBY_PATH%\bin\%~n1" ( set COMMAND=%PARAMS% ) else ( set COMMAND=ruby %PARAMS% ) ) :: Change current code page to 1252 as it is expected by Ruby @ for /f "usebackq tokens=2 delims=:" %%i in (`chcp`) do @ set CURRENTCP=%%i @ chcp 1252 > NUL :: Alter PATH and call our command @ set PATH=%RUBY_PATH%\bin;%PATH% @ call %COMMAND% @ set RETURN_VALUE=%ERRORLEVEL% :: Restore old code page @ chcp %CURRENTCP% > NUL :: Exit with return value @ exit /b %RETURN_VALUE% :RubyVersionNotFound @ echo(rbenv cannot determine the Ruby version to use. There are no valid global version nor '.ruby-version' file. @ exit /b 1 :RubyVersionNotManaged @ echo(Ruby %RUBY_VERSION% is not a version managed by rbenv. @ exit /b 1 :ScriptNotInThisRubyVersion @ echo(Ruby %RUBY_VERSION% does not contain a script '%~n1' @ exit /b 1
genezys/rbenv-cmd
libexec/rbenv_exec.cmd
Batchfile
mit
2,426
[ 30522, 1024, 1024, 15389, 1037, 10090, 3094, 2007, 1996, 2783, 2544, 1030, 2275, 4135, 9289, 9124, 10581, 20821, 10288, 9739, 10992, 1030, 2655, 1000, 1003, 1066, 1040, 2361, 2692, 9006, 8202, 1035, 13075, 2015, 1012, 4642, 2094, 1000, 1030...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import React from 'react'; import PropTypes from 'prop-types'; import { reduxForm } from 'redux-form'; import { connect } from 'react-redux'; import compose from 'recompose/compose'; import getDefaultValues from './getDefaultValues'; import FormField from './FormField'; import Toolbar from './Toolbar'; const noop = () => {}; export const SimpleForm = ({ children, handleSubmit, invalid, record, resource, basePath, submitOnEnter }) => { return ( <form onSubmit={ submitOnEnter ? handleSubmit : noop } className="simple-form"> <div style={{ padding: '0 1em 1em 1em' }}> {React.Children.map(children, input => input && ( <div key={input.props.source} className={`aor-input-${input.props.source}`} style={input.props.style}> <FormField input={input} resource={resource} record={record} basePath={basePath} /> </div> ))} </div> <Toolbar invalid={invalid} submitOnEnter={submitOnEnter} /> </form> ); }; SimpleForm.propTypes = { children: PropTypes.node, defaultValue: PropTypes.oneOfType([ PropTypes.object, PropTypes.func, ]), handleSubmit: PropTypes.func, invalid: PropTypes.bool, record: PropTypes.object, resource: PropTypes.string, basePath: PropTypes.string, validate: PropTypes.func, submitOnEnter: PropTypes.bool, }; SimpleForm.defaultProps = { submitOnEnter: true, }; const enhance = compose( connect((state, props) => ({ initialValues: getDefaultValues(state, props), })), reduxForm({ form: 'record-form', enableReinitialize: true, }), ); export default enhance(SimpleForm);
matteolc/admin-on-rest
src/mui/form/SimpleForm.js
JavaScript
mit
1,744
[ 30522, 12324, 10509, 2013, 1005, 10509, 1005, 1025, 12324, 17678, 13874, 2015, 2013, 1005, 17678, 1011, 4127, 1005, 1025, 12324, 1063, 2417, 5602, 14192, 1065, 2013, 1005, 2417, 5602, 1011, 2433, 1005, 1025, 12324, 1063, 7532, 1065, 2013, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * barsuift-simlife is a life simulator program * * Copyright (C) 2010 Cyrille GACHOT * * This file is part of barsuift-simlife. * * barsuift-simlife is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later * version. * * barsuift-simlife is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with barsuift-simlife. If not, see * <http://www.gnu.org/licenses/>. */ package barsuift.simLife.j3d.tree; import java.util.ArrayList; import java.util.List; import javax.media.j3d.BranchGroup; import javax.media.j3d.Transform3D; public class MockTreeBranch3D implements TreeBranch3D { private List<TreeLeaf3D> leaves; private float length; private float radius; private BranchGroup branchGroup; private TreeBranch3DState state; private int synchronizedCalled; private int increaseOneLeafSizeCalled; private Transform3D transform; public MockTreeBranch3D() { super(); reset(); } public void reset() { leaves = new ArrayList<TreeLeaf3D>(); length = 0; radius = 0; branchGroup = new BranchGroup(); state = new TreeBranch3DState(); synchronizedCalled = 0; increaseOneLeafSizeCalled = 0; transform = new Transform3D(); } @Override public List<TreeLeaf3D> getLeaves() { return leaves; } @Override public void addLeaf(TreeLeaf3D leaf3D) { leaves.add(leaf3D); } public void removeLeaf(TreeLeaf3D leaf3D) { leaves.remove(leaf3D); } @Override public float getLength() { return length; } public void setLength(float length) { this.length = length; } @Override public float getRadius() { return radius; } public void setRadius(float radius) { this.radius = radius; } @Override public BranchGroup getBranchGroup() { return branchGroup; } public void setGroup(BranchGroup branchGroup) { this.branchGroup = branchGroup; } @Override public TreeBranch3DState getState() { return state; } public void setState(TreeBranch3DState state) { this.state = state; } @Override public void synchronize() { this.synchronizedCalled++; } public int getNbSynchronize() { return synchronizedCalled; } @Override public void increaseOneLeafSize() { this.increaseOneLeafSizeCalled++; } public int getNbIncreaseOneLeafSizeCalled() { return increaseOneLeafSizeCalled; } @Override public Transform3D getTransform() { return transform; } public void setTransform(Transform3D transform) { this.transform = transform; } }
sdp0et/barsuift-simlife
simLifeDisplayAPI/src/test/java/barsuift/simLife/j3d/tree/MockTreeBranch3D.java
Java
gpl-3.0
3,316
[ 30522, 1013, 1008, 1008, 1008, 6963, 10179, 6199, 1011, 21934, 15509, 2003, 1037, 2166, 25837, 2565, 1008, 1008, 9385, 1006, 1039, 1007, 2230, 16049, 2571, 11721, 9905, 2102, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 6963, 10179, 6199, 1011...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const fs = require('fs') const path = require('path') const LRU = require('lru-cache') const express = require('express') const favicon = require('serve-favicon') const compression = require('compression') const resolve = file => path.resolve(__dirname, file) const { createBundleRenderer } = require('vue-server-renderer') const isProd = process.env.NODE_ENV === 'production' const useMicroCache = process.env.MICRO_CACHE !== 'false' const serverInfo = `express/${require('express/package.json').version} ` + `vue-server-renderer/${require('vue-server-renderer/package.json').version}` const app = express() const template = fs.readFileSync(resolve('./src/index.html'), 'utf-8'); function createRenderer (bundle, options) { // https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer return createBundleRenderer(bundle, Object.assign(options, { template, // for component caching cache: LRU({ max: 1000, maxAge: 1000 * 60 * 15 }), // this is only needed when vue-server-renderer is npm-linked basedir: resolve('./dist'), // recommended for performance runInNewContext: false })) } let renderer let readyPromise if (isProd) { // In production: create server renderer using built server bundle. // The server bundle is generated by vue-ssr-webpack-plugin. const bundle = require('./dist/vue-ssr-server-bundle.json') // The client manifests are optional, but it allows the renderer // to automatically infer preload/prefetch links and directly add <script> // tags for any async chunks used during render, avoiding waterfall requests. const clientManifest = require('./dist/vue-ssr-client-manifest.json') renderer = createRenderer(bundle, { clientManifest }) } else { // In development: setup the dev server with watch and hot-reload, // and create a new renderer on bundle / index template update. readyPromise = require('./build/setup-dev-server')(app, (bundle, options) => { renderer = createRenderer(bundle, options) }) } const serve = (path, cache) => express.static(resolve(path), { maxAge: cache && isProd ? 1000 * 60 * 60 * 24 * 30 : 0 }) app.use(compression({ threshold: 0 })) //app.use(favicon('./public/logo-48.png')) app.use('/dist', serve('./dist', true)) app.use('/public', serve('./public', true)) app.use('/manifest.json', serve('./manifest.json', true)) app.use('/service-worker.js', serve('./dist/service-worker.js')) // 1-second microcache. // https://www.nginx.com/blog/benefits-of-microcaching-nginx/ const microCache = LRU({ max: 100, maxAge: 1000 }) // since this app has no user-specific content, every page is micro-cacheable. // if your app involves user-specific content, you need to implement custom // logic to determine whether a request is cacheable based on its url and // headers. const isCacheable = req => useMicroCache function render (req, res) { const s = Date.now() res.setHeader("Content-Type", "text/html") res.setHeader("Server", serverInfo) const handleError = err => { if (err.url) { res.redirect(err.url) } else if(err.code === 404) { res.status(404).end('404 | Page Not Found') } else { // Render Error Page or Redirect res.status(500).end('500 | Internal Server Error') console.error(`error during render : ${req.url}`) console.error(err.stack) } } const cacheable = isCacheable(req) if (cacheable) { const hit = microCache.get(req.url) if (hit) { if (!isProd) { console.log(`cache hit!`) } return res.end(hit) } } const context = { title: '交易虎_手机游戏交易平台_手游交易_帐号交易_游戏币交易_装备交易_道具交易_jiaoyihu', // default title url: req.url } renderer.renderToString(context, (err, html) => { debugger; if (err) { return handleError(err) } res.end(html) if (cacheable) { microCache.set(req.url, html) } if (!isProd) { console.log(`whole request: ${Date.now() - s}ms`) } }) } app.get('*', isProd ? render : (req, res) => { readyPromise.then(() => render(req, res)) }) const port = process.env.PORT || 80; app.listen(port, () => { console.log(`server started at localhost:${port}`) })
wenyejie/trading-tiger
server.js
JavaScript
mit
4,301
[ 30522, 9530, 3367, 1042, 2015, 1027, 5478, 1006, 1005, 1042, 2015, 1005, 1007, 9530, 3367, 4130, 1027, 5478, 1006, 1005, 4130, 1005, 1007, 9530, 3367, 1048, 6820, 1027, 5478, 1006, 1005, 1048, 6820, 1011, 17053, 1005, 1007, 9530, 3367, 46...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php class Metabox { public static $boxes = array(); /** * @static * @param $type * @param $options * @return Metabox */ public static function factory($type, $options = null) { $parts = explode('_', $type); array_walk( $parts, function(&$item){ $item = ucfirst($item); } ); $class = 'Metabox_'.implode('_', $parts); if(class_exists($class)) { if( ! isset($options['type']) ) { $options['type'] = $type; } return new $class($options); } return false; } /** * @static * @param $key * @return Metabox */ public static function get($key) { return (isset(self::$boxes[$key]) ? self::$boxes[$key] : null); } public static function attr($box, $attr) { return (isset(self::$boxes[$box]->$attr) ? self::$boxes[$box]->$attr : null); } }
vladcazacu/Wordpress-HMVC
wp-content/themes/hmvc/core/classes/metabox.php
PHP
gpl-2.0
805
[ 30522, 1026, 1029, 25718, 2465, 18804, 8758, 1063, 2270, 10763, 1002, 8378, 1027, 9140, 1006, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 10763, 1008, 1030, 11498, 2213, 1002, 2828, 1008, 1030, 11498, 2213, 1002, 7047, 1008, 1030, 2709, 18804...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #nullable disable namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules { using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; public class SA1642CSharp10UnitTests : SA1642CSharp9UnitTests { } }
DotNetAnalyzers/StyleCopAnalyzers
StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1642CSharp10UnitTests.cs
C#
mit
393
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 5234, 4432, 12030, 1010, 11775, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 7000, 2104, 1996, 10210, 6105, 1012, 2156, 6105, 1999, 1996, 2622, 7117, 2005, 6105, 2592, 1012, 1001, 19701, 3085, 4487, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf-8 -*- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. # import unittest from mock import Mock from mock import patch from airflow import configuration from airflow.contrib.hooks.jira_hook import JiraHook from airflow import models from airflow.utils import db jira_client_mock = Mock( name="jira_client" ) class TestJiraHook(unittest.TestCase): def setUp(self): configuration.load_test_config() db.merge_conn( models.Connection( conn_id='jira_default', conn_type='jira', host='https://localhost/jira/', port=443, extra='{"verify": "False", "project": "AIRFLOW"}')) @patch("airflow.contrib.hooks.jira_hook.JIRA", autospec=True, return_value=jira_client_mock) def test_jira_client_connection(self, jira_mock): jira_hook = JiraHook() self.assertTrue(jira_mock.called) self.assertIsInstance(jira_hook.client, Mock) self.assertEqual(jira_hook.client.name, jira_mock.return_value.name) if __name__ == '__main__': unittest.main()
akosel/incubator-airflow
tests/contrib/hooks/test_jira_hook.py
Python
apache-2.0
1,861
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 1001, 1001, 7000, 2000, 1996, 15895, 4007, 3192, 1006, 2004, 2546, 1007, 2104, 2028, 1001, 2030, 2062, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>generic::raw_protocol::protocol</title> <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="../../../boost_asio.html" title="Boost.Asio"> <link rel="up" href="../generic__raw_protocol.html" title="generic::raw_protocol"> <link rel="prev" href="operator_eq__eq_.html" title="generic::raw_protocol::operator=="> <link rel="next" href="raw_protocol.html" title="generic::raw_protocol::raw_protocol"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> <td align="center"><a href="../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="operator_eq__eq_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../generic__raw_protocol.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="raw_protocol.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> <a name="boost_asio.reference.generic__raw_protocol.protocol"></a><a class="link" href="protocol.html" title="generic::raw_protocol::protocol">generic::raw_protocol::protocol</a> </h4></div></div></div> <p> <a class="indexterm" name="idp142797472"></a> Obtain an identifier for the protocol. </p> <pre class="programlisting"><span class="keyword">int</span> <span class="identifier">protocol</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> </pre> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2017 Christopher M. Kohlhoff<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="operator_eq__eq_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../generic__raw_protocol.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="raw_protocol.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
cris-iisc/mpc-primitives
crislib/libscapi/lib/boost_1_64_0/doc/html/boost_asio/reference/generic__raw_protocol/protocol.html
HTML
agpl-3.0
3,321
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869, 13462, 1027, 2149, 1011, 2004, 6895, 2072, 1000, 1028, 1026, 2516,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# # Dockerfile for shadowsocks-libev # FROM alpine:3.4 MAINTAINER Wind4 <puxiaping@gmail.com> ENV BUILD_DEPS autoconf build-base curl libtool linux-headers openssl-dev asciidoc xmlto RUN apk add --update $BUILD_DEPS ENV BUILD_VER 2.5.0 RUN BUILD_SRC=https://github.com/shadowsocks/shadowsocks-libev/archive/v$BUILD_VER.tar.gz \ && BUILD_DIR=shadowsocks-libev-$BUILD_VER \ && curl -sSL $BUILD_SRC | tar xz \ && cd $BUILD_DIR \ && ./configure \ && make install \ && cd .. \ && rm -rf $BUILD_DIR \ && apk del --purge $BUILD_DEPS \ && rm -rf /var/cache/apk/* ENTRYPOINT ["/usr/local/bin/ss-server"] CMD ["-h"]
Wind4/docker-library
shadowsocks-libev/Dockerfile
Dockerfile
mit
618
[ 30522, 1001, 1001, 8946, 2121, 8873, 2571, 2005, 6281, 25384, 1011, 5622, 4783, 2615, 1001, 2013, 10348, 1024, 1017, 1012, 1018, 5441, 2121, 3612, 2549, 1026, 16405, 14787, 4691, 1030, 20917, 4014, 1012, 4012, 1028, 4372, 2615, 3857, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<svg version="1.1" class="o-icon__camera" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 277.3 203" style="enable-background:new 0 0 277.3 203;" xml:space="preserve"> <style type="text/css"> .st0{fill:#302D33;} .st1{fill:none;stroke:#302D33;stroke-width:2;stroke-miterlimit:10;} .st2{fill:none;stroke:#302D33;stroke-miterlimit:10;} .st3{fill:none;stroke:#ebe8e4;stroke-width:2;stroke-miterlimit:10;} </style> <rect x="235.7" y="58" class="st1" width="4" height="15"/> <rect x="37.7" y="58" class="st1" width="4" height="15"/> <path class="st0" d="M197.2,78.4c-3,0-5.5-2.5-5.5-5.5s2.5-5.5,5.5-5.5s5.5,2.5,5.5,5.5S200.2,78.4,197.2,78.4z"/> <g id="XMLID_1_"> <g> <path class="st0" d="M146.5,67.4c23.4,0,42.5,19.1,42.5,42.5s-19.1,42.5-42.5,42.5S104,133.3,104,109.9S123,67.4,146.5,67.4z"/> <path class="st0" d="M236.7,54v115h-195V52h63.8v2h-8.8c-12,19-18.1,38.1-18.1,56.9c0,18.7,6.1,37.5,18,56.1h137.9V54H236.7z"/> <path class="st0" d="M236.7,52v2h-2h-46.6h-0.4h-81.4h-0.4h-0.4v-2l19.2-18h44.5l19.2,18H236.7z M112.7,48h68.6l-12.8-12h-42.9 L112.7,48z"/> <path class="st0" d="M81.7,45v6h-27v-6h6v-4h15v4H81.7z M79.7,49v-2h-6h-11h-6v2H79.7z"/> </g> </g> <line class="st1" x1="211.8" y1="167.6" x2="235.3" y2="143.8"/> <line class="st1" x1="217.3" y1="168.3" x2="235.9" y2="149.4"/> <line class="st1" x1="223.5" y1="167.8" x2="235.4" y2="155.7"/> <line class="st1" x1="229.2" y1="168.3" x2="235.9" y2="161.5"/> <g> <line class="st2" x1="56.6" y1="45.7" x2="56.6" y2="50"/> <line class="st2" x1="59.5" y1="45.7" x2="59.5" y2="50"/> <line class="st2" x1="62.4" y1="45.7" x2="62.4" y2="50"/> <line class="st2" x1="65.3" y1="45.7" x2="65.3" y2="50"/> <line class="st2" x1="68.2" y1="45.7" x2="68.2" y2="50"/> <line class="st2" x1="71.1" y1="45.7" x2="71.1" y2="50"/> <line class="st2" x1="74" y1="45.7" x2="74" y2="50"/> <line class="st2" x1="76.9" y1="45.6" x2="76.9" y2="50"/> <line class="st2" x1="79.8" y1="45.6" x2="79.8" y2="50"/> </g> </svg>
kfriedgen/friedgen-starter
templates/icons/camera.php
PHP
mit
2,037
[ 30522, 1026, 17917, 2290, 2544, 1027, 1000, 1015, 1012, 1015, 1000, 2465, 1027, 1000, 1051, 1011, 12696, 1035, 1035, 4950, 1000, 8909, 1027, 1000, 6741, 1035, 1015, 1000, 20950, 3619, 1027, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef LIGHTNET_SUBSAMPLE_MODULE_H #define LIGHTNET_SUBSAMPLE_MODULE_H #include "module.h" using namespace std; using FeatureMap = vector<vector<Neuron*>>; FeatureMap* matrifyNeurons(vector<Neuron*>& v, int sizex, int sizey) { FeatureMap *fmap = new FeatureMap(); fmap->resize(sizex); int z = 0; for(unsigned int x = 0; x < fmap->size(); x++) { fmap->at(x).resize(sizey); for(unsigned int y = 0; y < fmap->at(x).size(); y++) { fmap->at(x).at(y) = v.at(z); z++; } } return fmap; } class SubsampleModule : public Module { private: int inputSize; double lowerWeightLimit,upperWeightLimit; int sizex, sizey, numFeatures, featureSize; vector<FeatureMap*> featureMaps; public: SubsampleModule(int numFeatures, int sizex, int sizey) { this->sizex = sizex; this->sizey = sizey; this->featureSize = sizex*sizey; this->numFeatures = numFeatures; for(int n = 0; n < featureSize*numFeatures/pow(2,2); n++) { neurons.push_back(new Neuron(0.25, 0.25)); } for(int f = 0; f < numFeatures; f++) { vector<Neuron*> v(neurons.begin()+(f*floor(sizex/2.0)*floor(sizey/2.0)),neurons.begin()+((f+1)*floor(sizex/2.0)*floor(sizey/2.0))); featureMaps.push_back(matrifyNeurons(v,floor(sizex/2.0),floor(sizey/2.0))); } } void connect(Module* prev) { int z = 0; for(int f = 0; f < numFeatures; f++) { vector<Neuron*> v(prev->getNeurons().begin()+(f*sizex*sizey),prev->getNeurons().begin()+((f+1)*sizex*sizey)); FeatureMap* fmap = matrifyNeurons(v,sizex,sizey); for(int fx = 0; fx < featureMaps[f]->size(); fx++) { for(int fy = 0; fy < featureMaps[f]->at(0).size(); fy++) { for(int ix = fx*2; ix < fx*2 + 2; ix++) { for(int iy = fy*2; iy < fy*2 + 2; iy++) { //cout << f << " connecting " << fx << "," << fy << " to " << ix << "," << iy << endl; featureMaps[f]->at(fx).at(fy)->connect(fmap->at(ix).at(iy),new Weight()); } } } } } //cout << "size " << neurons.size() << endl; } void gradientDescent(double learningRate) {} }; #endif
DariusBxsci/LightNet
include/modules/SubsampleModule.h
C
gpl-3.0
2,230
[ 30522, 1001, 2065, 13629, 2546, 2422, 7159, 1035, 4942, 21559, 10814, 1035, 11336, 1035, 1044, 1001, 9375, 2422, 7159, 1035, 4942, 21559, 10814, 1035, 11336, 1035, 1044, 1001, 2421, 1000, 11336, 1012, 1044, 1000, 2478, 3415, 15327, 30524, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php use yii\helpers\Html; ?> <?php foreach ($_model as $photo): ?> <div class="thumb" style="float:left;padding: 2px" data-name="<?= $photo->name ?>" onclick="ShowFullImage('<?= $photo->name ?>')" > <div> <?= Html::img('/upload/multy-thumbs/' . $photo->name, ['height' => '70px']); ?> </div> <div style="" > <?= $photo->name; ?> </div> </div> <?php endforeach; ?> <style> .jpreloader.back_background{ background-color: #111214; bottom: 0; height: 100%; left: 0; opacity: 0.9; position: fixed; right: 0; top: 0; width: 100%; display: block; background-image: url("/img/preloader.gif"); background-repeat: no-repeat; background-position:center center; } </style>
kotmonstr/kotmonstr
frontend/modules/image/views/default/get-photo.php
PHP
bsd-3-clause
1,011
[ 30522, 1026, 1029, 25718, 2224, 12316, 2072, 1032, 2393, 2545, 1032, 16129, 1025, 1029, 1028, 1026, 1029, 25718, 18921, 6776, 1006, 1002, 1035, 2944, 2004, 1002, 6302, 1007, 1024, 1029, 1028, 1026, 4487, 2615, 2465, 1027, 1000, 7639, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
-- savepoint.test -- -- execsql { RELEASE "including Whitespace " } RELEASE "including Whitespace "
bkiers/sqlite-parser
src/test/resources/savepoint.test_86.sql
SQL
mit
100
[ 30522, 1011, 1011, 3828, 8400, 1012, 3231, 1011, 1011, 1011, 1011, 4654, 8586, 2015, 4160, 2140, 1063, 2713, 1000, 2164, 12461, 15327, 1000, 1065, 2713, 1000, 2164, 12461, 15327, 1000, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env python """ Grid time ============= """ from datetime import timedelta import numpy as np from opendrift.readers import reader_global_landmask from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.oceandrift import OceanDrift # Seeding at a grid at regular interval o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') #%% # Landmask reader_landmask = reader_global_landmask.Reader( extent=[4.0, 5.5, 59.9, 61.2]) o.add_reader([reader_landmask, reader_norkyst]) #%% # Seeding some particles lons = np.linspace(4.4, 4.6, 10) lats = np.linspace(60.0, 60.1, 10) lons, lats = np.meshgrid(lons, lats) lons = lons.ravel() lats = lats.ravel() #%% # Seed oil elements on a grid at regular time interval start_time = reader_norkyst.start_time time_step = timedelta(hours=6) num_steps = 10 for i in range(num_steps+1): o.seed_elements(lons, lats, radius=0, number=100, time=start_time + i*time_step) #%% # Running model for 60 hours o.run(steps=60*4, time_step=900, time_step_output=3600) #%% # Print and plot results print(o) o.animation(fast=True) #%% # .. image:: /gallery/animations/example_grid_time_0.gif
OpenDrift/opendrift
examples/example_grid_time.py
Python
gpl-2.0
1,348
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 18750, 1000, 1000, 1000, 8370, 2051, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1000, 1000, 1000, 2013, 3058, 7292, 12324, 22313, 20042, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** @file connectmodule.h @brief Contains ConnectModule - Call Module for connection establishment at incoming connection @author Gernot Hillier <gernot@hillier.de> $Revision: 1.5 $ */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CONNECTMODULE_H #define CONNECTMODULE_H #include "callmodule.h" #include "../backend/connection.h" using namespace std; /** @brief Call Module for connection establishment at incoming connection This module serves to accept an incoming call and wait for the connection establishment. It is the first module you should call when an incoming call is signalled and you want to accept it. @author Gernot Hillier */ class ConnectModule: public CallModule { public: /** @brief Constructor. Create object. @param conn reference to Connection object @param service service to connect with as described in Connection::service_t @param faxStationID fax station ID, only necessary when connecting in FAXG3 mode @param faxHeadline fax headline, only necessary when connecting in FAXG3 mode @throw CapiExternalError Thrown if Connection already up @throw CapiWrongState Thrown if Connection not in waiting state */ ConnectModule(Connection *conn, Connection::service_t service, string faxStationID, string faxHeadline) throw (CapiWrongState,CapiExternalError); /** @brief Accept connection and wait for complete establishment @throw CapiExternalError Thrown by Connection::connectWaiting() @throw CapiMsgError Thrown by Connection::connectWaiting() @throw CapiWrongState Thrown by Connection::connectWaiting() */ void mainLoop() throw (CapiWrongState,CapiExternalError, CapiMsgError); /** @brief Finish mainLoop() if call is completely established */ void callConnected(); private: Connection::service_t service; ///< service with which we should connect string faxStationID, ///< fax Station ID to use faxHeadline; ///< fax headlint to use }; #endif /* History Old Log (for new changes see ChangeLog): Revision 1.4 2003/12/31 16:28:55 gernot * src/modules/connectmodule.{h,cpp} (ConnectModule): throw CapiExternalError only when connection's already up, otherwise use CapiWrongState Revision 1.3 2003/12/28 21:01:04 gernot - reworked TODO, disabled automatic log message adding to source files Revision 1.1.1.1 2003/02/19 08:19:53 gernot initial checkin of 0.4 Revision 1.7 2002/11/29 10:27:44 ghillie - updated comments, use doxygen format now Revision 1.6 2002/11/25 11:57:19 ghillie - use service_type instead of CIP value in application layer Revision 1.5 2002/11/22 15:18:56 ghillie added faxStationID, faxHeadline parameters Revision 1.4 2002/11/21 15:33:44 ghillie - moved code from constructor/destructor to overwritten mainLoop() method Revision 1.3 2002/11/20 17:25:29 ghillie added missing throw() declaration Revision 1.2 2002/11/19 15:57:19 ghillie - Added missing throw() declarations - phew. Added error handling. All exceptions are caught now. Revision 1.1 2002/11/14 17:05:58 ghillie initial checkin */
larsimmisch/capisuite
src/modules/connectmodule.h
C
gpl-2.0
3,710
[ 30522, 1013, 1008, 1008, 1030, 5371, 7532, 5302, 8566, 2571, 1012, 1044, 1030, 4766, 3397, 7532, 5302, 8566, 2571, 1011, 2655, 11336, 2005, 4434, 5069, 2012, 14932, 4434, 1030, 3166, 16216, 19139, 2102, 2940, 3771, 1026, 16216, 19139, 2102,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="page-content container"> <div class="col-xs-10 col-xs-offset-1"> <div class="area padding-15 text-center"> <button class="btn needs-btn" ui-sref="demand.list">前往需求列表</button> </div> <div class="area bg-white"> <h4 class="text-green font-bold"><i class="glyphicon glyphicon-list-alt"></i> 推荐阅读</h4> <p class="read-content row clearfix"> <span class="col-xs-6"> <a class="text-muted" ui-sref="reading.rules">商品发布规则</a> </span> <span class="col-xs-6"> <a class="text-muted" ui-sref="reading.iphone">购买二手iPhone注意事项</a> </span> </p> </div> <div class="area"> <div class="area-header text-center"> <h3 class="page-title-wrap"> <span class="page-title-content"><i class="iconfont icon-xin text-red page-title-icon"></i>最新上架</span> </h3> </div> <div class="row"> <div ui-sref="goods.details({id: item._id})" class="col-xs-3" ng-repeat="item in vm.recentGoods"> <img-reset img-data="item"></img-reset> </div> </div> </div> <div class="area"> <div class="area-header text-center"> <h3 class="page-title-wrap"> <span class="page-title-content"><i class="iconfont icon-shoucangjia text-red page-title-icon"></i>收藏最多</span> </h3> </div> <div class="row"> <div ui-sref="goods.details({id: item._id})" class="col-xs-3" ng-repeat="item in vm.collectedMostGoods"> <img-reset img-data="item"></img-reset> </div> </div> </div> <div class="area"> <div class="area-header text-center"> <h3 class="page-title-wrap"> <span class="page-title-content"><i class="iconfont icon-kejian text-red page-title-icon"></i>浏览最多</span> </h3> </div> <div class="row"> <div ui-sref="goods.details({id: item._id})" class="col-xs-3" ng-repeat="item in vm.pvMostGoods"> <img-reset img-data="item"></img-reset> </div> </div> </div> </div> </div>
SWPUliusong/second-hand-street
second-hand-street-FE/src/modules/goodsList/templates/home.html
HTML
mit
2,483
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 3931, 1011, 4180, 11661, 1000, 1028, 1026, 4487, 2615, 2465, 1027, 1000, 8902, 1011, 1060, 2015, 1011, 2184, 8902, 1011, 1060, 2015, 1011, 16396, 1011, 1015, 1000, 1028, 1026, 4487, 2615, 2465, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Single listing page map. * * @since 1.0.0 * @package Easy_Listings_Map * @subpackage Easy_Listings_Map/public * @author Taher Atashbar<taher.atashbar@gmail.com> */ class ELM_Public_Single_Map extends ELM_Public_Controller { /** * Plugin public-face. * * @since 1.0.0 * @var Easy_Listings_Map_Public */ private $plugin_public; /** * Settings of map like styles and etc. * * @since 1.0.0 * @var array */ private $settings; /** * Data of map that will send to map js file. * * @since 1.0.0 * @var array */ private $data; public function __construct( Easy_Listings_Map_Public $plugin_public ) { $this->plugin_public = $plugin_public; $elm_settings = ELM_IOC::make( 'settings' )->get_settings(); $single_map_enabled = ! empty( $elm_settings['map_in_single_page'] ) ? $elm_settings['map_in_single_page'] : 'enabled'; if ( $single_map_enabled == 'enabled' ) { if ( remove_action( 'epl_property_map', 'epl_property_map_default_callback' ) ) { // Setting map specific settings. $this->settings['map_height'] = ! empty( $elm_settings['single_page_map_height'] ) ? $elm_settings['single_page_map_height'] : '400'; // Setting map specific data. $this->data['zoom'] = ! empty( $elm_settings['single_page_map_zoom'] ) ? trim( $elm_settings['single_page_map_zoom'] ) : '17'; $this->data['map_id'] = 'elm-singular-map'; $this->data['map_types'] = ! empty( $elm_settings['single_page_map_types'] ) ? array_values( $elm_settings['single_page_map_types'] ) : array( 'ROADMAP' ); $this->data['default_map_type'] = ! empty( $elm_settings['single_page_map_default_type'] ) ? $elm_settings['single_page_map_default_type'] : 'ROADMAP'; $this->data['map_styles'] = isset( $elm_settings['single_page_map_styles'] ) ? trim( $elm_settings['single_page_map_styles'] ) : ''; // Adding action for showing map. $this->plugin_public->get_loader()->add_action( 'epl_property_map', $this, 'display_single_listing_map' ); } } } /** * action-callback for displaying map in single listing page. * * @since 1.0.0 */ public function display_single_listing_map() { $address_coordinates = get_post_meta( get_the_ID(), 'property_address_coordinates', true ); if ( strlen( $address_coordinates ) > 0 ) { $coordinates = explode( ',', $address_coordinates, 2 ); // Checking coordinates for lat and lon if ( isset( $coordinates[0] ) && isset( $coordinates[1] ) ) { $this->data['latitude'] = trim( $coordinates[0] ); $this->data['longitude'] = trim( $coordinates[1] ); $this->draw_map(); } } } /** * Registering scripts of map. * * @since 1.0.0 */ public function register_scripts() { $api_key = epl_get_option( 'epl_google_api_key' ); $api_key = empty( $api_key ) ? 'AIzaSyCBpgWp8d61yCDUgJVcy1-MOUogxbSzVRI' : $api_key; $protocol = is_ssl() ? 'https' : 'http'; // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; // Register the script first. wp_register_script( 'elm-google-map-v-3', $protocol . '://maps.googleapis.com/maps/api/js?v=3.exp' . ( ! empty( $api_key ) ? '&key=' . esc_attr( $api_key ) : '' ) ); wp_enqueue_script( 'elm_singular_google_map', $this->get_js_url() . 'maps/elm-singular-google-map' . $suffix . '.js', array( 'jquery', 'elm-google-map-v-3' ), $this->plugin_public->get_version(), true ); wp_localize_script( 'elm_singular_google_map', 'elm_singular_map', $this->data ); wp_enqueue_style( 'elm-google-maps', $this->get_css_url() . 'elm-google-maps' . $suffix . '.css' ); } /** * Drawing map element content. * * @since 1.0.0 */ protected function draw_map() { $this->render_view( 'maps.singular-map-content', array( 'controller' => $this, 'map_height' => $this->settings['map_height'], 'map_id' => $this->data['map_id'], ) ); } /** * Getting data of singular map. * * @since 1.0.0 * @return array array of data */ public function get_data() { return $this->data; } /** * Getting settings of singular map * * @since 1.0.0 * @return array array of settings */ public function get_settings() { return $this->settings; } }
codewp/easy-listings-map
public/class-easy-listings-map-public-single-map.php
PHP
gpl-2.0
4,371
[ 30522, 1026, 1029, 25718, 1013, 1013, 6164, 2065, 11570, 3495, 2065, 1006, 999, 4225, 1006, 1005, 14689, 15069, 1005, 1007, 1007, 1063, 6164, 1025, 1065, 1013, 1008, 1008, 1008, 2309, 10328, 3931, 4949, 1012, 1008, 1008, 1030, 2144, 1015, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef AABB_UTIL2 #define AABB_UTIL2 #include "btTransform.h" #include "btVector3.h" #include "btMinMax.h" SIMD_FORCE_INLINE void AabbExpand (btVector3& aabbMin, btVector3& aabbMax, const btVector3& expansionMin, const btVector3& expansionMax) { aabbMin = aabbMin + expansionMin; aabbMax = aabbMax + expansionMax; } /// conservative test for overlap between two aabbs SIMD_FORCE_INLINE bool TestPointAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, const btVector3 &point) { bool overlap = true; overlap = (aabbMin1.getX() > point.getX() || aabbMax1.getX() < point.getX()) ? false : overlap; overlap = (aabbMin1.getZ() > point.getZ() || aabbMax1.getZ() < point.getZ()) ? false : overlap; overlap = (aabbMin1.getY() > point.getY() || aabbMax1.getY() < point.getY()) ? false : overlap; return overlap; } /// conservative test for overlap between two aabbs SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, const btVector3 &aabbMin2, const btVector3 &aabbMax2) { bool overlap = true; overlap = (aabbMin1.getX() > aabbMax2.getX() || aabbMax1.getX() < aabbMin2.getX()) ? false : overlap; overlap = (aabbMin1.getZ() > aabbMax2.getZ() || aabbMax1.getZ() < aabbMin2.getZ()) ? false : overlap; overlap = (aabbMin1.getY() > aabbMax2.getY() || aabbMax1.getY() < aabbMin2.getY()) ? false : overlap; return overlap; } /// conservative test for overlap between triangle and aabb SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const btVector3 *vertices, const btVector3 &aabbMin, const btVector3 &aabbMax) { const btVector3 &p1 = vertices[0]; const btVector3 &p2 = vertices[1]; const btVector3 &p3 = vertices[2]; if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; return true; } SIMD_FORCE_INLINE int btOutcode(const btVector3& p,const btVector3& halfExtent) { return (p.getX() < -halfExtent.getX() ? 0x01 : 0x0) | (p.getX() > halfExtent.getX() ? 0x08 : 0x0) | (p.getY() < -halfExtent.getY() ? 0x02 : 0x0) | (p.getY() > halfExtent.getY() ? 0x10 : 0x0) | (p.getZ() < -halfExtent.getZ() ? 0x4 : 0x0) | (p.getZ() > halfExtent.getZ() ? 0x20 : 0x0); } SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom, const btVector3& rayInvDirection, const unsigned int raySign[3], const btVector3 bounds[2], btScalar& tmin, btScalar lambda_min, btScalar lambda_max) { btScalar tmax, tymin, tymax, tzmin, tzmax; tmin = (bounds[raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX(); tmax = (bounds[1-raySign[0]].getX() - rayFrom.getX()) * rayInvDirection.getX(); tymin = (bounds[raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY(); tymax = (bounds[1-raySign[1]].getY() - rayFrom.getY()) * rayInvDirection.getY(); if ( (tmin > tymax) || (tymin > tmax) ) return false; if (tymin > tmin) tmin = tymin; if (tymax < tmax) tmax = tymax; tzmin = (bounds[raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ(); tzmax = (bounds[1-raySign[2]].getZ() - rayFrom.getZ()) * rayInvDirection.getZ(); if ( (tmin > tzmax) || (tzmin > tmax) ) return false; if (tzmin > tmin) tmin = tzmin; if (tzmax < tmax) tmax = tzmax; return ( (tmin < lambda_max) && (tmax > lambda_min) ); } SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom, const btVector3& rayTo, const btVector3& aabbMin, const btVector3& aabbMax, btScalar& param, btVector3& normal) { btVector3 aabbHalfExtent = (aabbMax-aabbMin)* btScalar(0.5); btVector3 aabbCenter = (aabbMax+aabbMin)* btScalar(0.5); btVector3 source = rayFrom - aabbCenter; btVector3 target = rayTo - aabbCenter; int sourceOutcode = btOutcode(source,aabbHalfExtent); int targetOutcode = btOutcode(target,aabbHalfExtent); if ((sourceOutcode & targetOutcode) == 0x0) { btScalar lambda_enter = btScalar(0.0); btScalar lambda_exit = param; btVector3 r = target - source; int i; btScalar normSign = 1; btVector3 hitNormal(0,0,0); int bit=1; for (int j=0;j<2;j++) { for (i = 0; i != 3; ++i) { if (sourceOutcode & bit) { btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i]; if (lambda_enter <= lambda) { lambda_enter = lambda; hitNormal.setValue(0,0,0); hitNormal[i] = normSign; } } else if (targetOutcode & bit) { btScalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i]; btSetMin(lambda_exit, lambda); } bit<<=1; } normSign = btScalar(-1.); } if (lambda_enter <= lambda_exit) { param = lambda_enter; normal = hitNormal; return true; } } return false; } SIMD_FORCE_INLINE void btTransformAabb(const btVector3& halfExtents, btScalar margin,const btTransform& t,btVector3& aabbMinOut,btVector3& aabbMaxOut) { btVector3 halfExtentsWithMargin = halfExtents+btVector3(margin,margin,margin); btMatrix3x3 abs_b = t.getBasis().absolute(); btVector3 center = t.getOrigin(); btVector3 extent = btVector3(abs_b[0].dot(halfExtentsWithMargin), abs_b[1].dot(halfExtentsWithMargin), abs_b[2].dot(halfExtentsWithMargin)); aabbMinOut = center - extent; aabbMaxOut = center + extent; } SIMD_FORCE_INLINE void btTransformAabb(const btVector3& localAabbMin,const btVector3& localAabbMax, btScalar margin,const btTransform& trans,btVector3& aabbMinOut,btVector3& aabbMaxOut) { btAssert(localAabbMin.getX() <= localAabbMax.getX()); btAssert(localAabbMin.getY() <= localAabbMax.getY()); btAssert(localAabbMin.getZ() <= localAabbMax.getZ()); btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin); localHalfExtents+=btVector3(margin,margin,margin); btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin); btMatrix3x3 abs_b = trans.getBasis().absolute(); btVector3 center = trans(localCenter); btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), abs_b[1].dot(localHalfExtents), abs_b[2].dot(localHalfExtents)); aabbMinOut = center-extent; aabbMaxOut = center+extent; } #define USE_BANCHLESS 1 #ifdef USE_BANCHLESS //This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360) SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) { return static_cast<unsigned int>(btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) & (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2]) & (aabbMin1[1] <= aabbMax2[1]) & (aabbMax1[1] >= aabbMin2[1])), 1, 0)); } #else SIMD_FORCE_INLINE bool testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) { bool overlap = true; overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap; overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap; overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap; return overlap; } #endif //USE_BANCHLESS #endif
jonan/freedom-to-smash
bullet/LinearMath/btAabbUtil2.h
C
gpl-3.0
8,605
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2494, 1011, 2294, 18353, 2080, 3158, 7939, 12674, 1013, 22209, 2522, 19042, 2015, 8299, 1024, 1013, 1013, 7142, 15638, 1012, 4012, 1013, 7960, 1013, 2023, 4007, 2003, 3024, 1005, 2004, 1011, 2003, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var utils = require('../../../utils'); module.exports = function CodeType(config) { var self = { selector: '.field-type-code[for="' + config.fieldName + '"]', elements: { label: '.FormLabel', lineNumber: '.CodeMirror-linenumber', codeMirror: '.CodeMirror-container', }, commands: [{ assertUI: function() { this .expect.element('@label').to.be.visible; this .expect.element('@label').text.to.equal(utils.titlecase(config.fieldName)); this .expect.element('@lineNumber').to.be.visible; this .expect.element('@lineNumber').text.to.equal('1'); this .expect.element('@codeMirror').to.be.visible; return this; }, fillInput: function(input) { this.api .execute(function (selector, input) { var x = document.querySelector(selector); var y = x.getElementsByClassName('CodeMirror')[0]; y.CodeMirror.setValue(input.value); }, [self.selector, input]); return this; }, assertInput: function(input) { this.api .execute(function (selector) { var x = document.querySelector(selector); var y = x.getElementsByClassName('CodeMirror')[0]; return y.CodeMirror.getValue(); }, [self.selector], function (result) { this.assert.equal(result.value, input.value); }); return this; }, }], }; return self; };
webteckie/keystone
test/e2e/adminUI/pages/fieldTypes/code.js
JavaScript
mit
1,358
[ 30522, 13075, 21183, 12146, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 21183, 12146, 1005, 1007, 1025, 11336, 1012, 14338, 1027, 3853, 3642, 13874, 1006, 9530, 8873, 2290, 1007, 1063, 13075, 2969, 1027, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
if not String.method_defined? :to_underscore class String # ruby mutation methods have the expectation to return self if a mutation # occurred, nil otherwise. # (see http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub-21) def to_underscore! gsub!(/(.)([A-Z])/,'\1_\2') && downcase! end def to_underscore dup.tap { |s| s.to_underscore! } end end end
binford2k/arnold
gem/lib/arnold/monkeypatch.rb
Ruby
mit
412
[ 30522, 2065, 2025, 5164, 1012, 4118, 1035, 4225, 1029, 1024, 2000, 1035, 2104, 9363, 2890, 2465, 5164, 1001, 10090, 16221, 4725, 2031, 1996, 17626, 2000, 2709, 2969, 2065, 1037, 16221, 1001, 4158, 1010, 9152, 2140, 4728, 1012, 1001, 1006, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Copyright (c) 2015 Ultimaker B.V. # Uranium is released under the terms of the AGPLv3 or higher. from UM.Math.Float import Float # For fuzzy comparison of edge cases. ## Represents a line segment in 2D. # # The line segment is represented by two endpoints. class LineSegment(object): ## Creates a new line segment with the specified endpoints. # # \param endpoint_a An endpoint of the line segment. # \param endpoint_b An endpoint of the line segment. def __init__(self, endpoint_a, endpoint_b): self._endpoint_a = endpoint_a self._endpoint_b = endpoint_b ## Gets the second endpoint (B) of the line segment. # # \return The second endpoint of the line segment. def getEnd(self): return self._endpoint_b ## Gets the first endpoint (A) of the line segment. # # \return The first endpoint of the line segment. def getStart(self): return self._endpoint_a ## Returns the point of intersection of this line segment with another line # segment, if any. # # \param other The line segment to check intersection with. # \return The intersection point if they intersect, or None otherwise. def intersection(self, other): if not self.intersectsWithLine(other._endpoint_a, other._endpoint_b) or not other.intersectsWithLine(self._endpoint_a, self._endpoint_b): #Line segments don't intersect. return None direction_me = self._endpoint_b - self._endpoint_a direction_other = other._endpoint_b - other._endpoint_a diff_endpoint_a = self._endpoint_a - other._endpoint_a perpendicular = direction_me.perpendicular() denominator = perpendicular.dot(direction_other) #Project onto the perpendicular. numerator = perpendicular.dot(diff_endpoint_a) if denominator == 0: #Lines are parallel. return None return (numerator / denominator.astype(float)) * direction_other + other._endpoint_a ## Returns whether the line segment intersects the specified (infinite) # line. # # If the line segment touches the line with one or both endpoints, that # counts as an intersection too. # # \param a A point on the line to intersect with. # \param b A different point on the line to intersect with. # \return True if the line segment intersects with the line, or False # otherwise. def intersectsWithLine(self, a, b): shifted_b = b - a #It intersects if either endpoint is on the line, or if one endpoint is on the right but the other is not. return Float.fuzzyCompare(shifted_b.cross(self._endpoint_a), 0) or Float.fuzzyCompare(shifted_b.cross(self._endpoint_b), 0) or (self._pointIsRight(self._endpoint_a, a, b) != self._pointIsRight(self._endpoint_b, a, b)) ## Determines whether point p is to the right of the line through a and b. # # \param p The point to determine whether it is to the right of the line. # \param a A point on the line. # \param b Another point on the line. def _pointIsRight(self, p, a, b): shifted_end = b - a return shifted_end.cross(p - a) < 0
onitake/Uranium
UM/Math/LineSegment.py
Python
agpl-3.0
3,205
[ 30522, 1001, 9385, 1006, 1039, 1007, 2325, 17359, 3775, 8571, 1038, 1012, 1058, 1012, 1001, 14247, 2003, 2207, 2104, 1996, 3408, 1997, 1996, 12943, 24759, 2615, 2509, 2030, 3020, 1012, 2013, 8529, 1012, 8785, 1012, 14257, 12324, 14257, 1001...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/************************************************************* * * MathJax/jax/output/HTML-CSS/fonts/Neo-Euler/Variants/Regular/Main.js * * Copyright (c) 2013-2014 The MathJax Consortium * * 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. */ MathJax.OutputJax['HTML-CSS'].FONTDATA.FONTS['NeoEulerMathJax_Variants'] = { directory: 'Variants/Regular', family: 'NeoEulerMathJax_Variants', testString: '\u00A0\u2032\u2033\u2034\u2035\u2036\u2037\u2057\uE200\uE201\uE202\uE203\uE204\uE205\uE206', 0x20: [0,0,333,0,0], 0xA0: [0,0,333,0,0], 0x2032: [559,-41,329,48,299], 0x2033: [559,-41,640,48,610], 0x2034: [559,-41,950,48,920], 0x2035: [559,-41,329,48,299], 0x2036: [559,-41,640,48,610], 0x2037: [559,-41,950,48,919], 0x2057: [559,-41,1260,48,1230], 0xE200: [493,13,501,41,456], 0xE201: [469,1,501,46,460], 0xE202: [474,-1,501,59,485], 0xE203: [474,182,501,38,430], 0xE204: [476,192,501,10,482], 0xE205: [458,184,501,47,441], 0xE206: [700,13,501,45,471], 0xE207: [468,181,501,37,498], 0xE208: [706,10,501,40,461], 0xE209: [470,182,501,27,468] }; MathJax.Callback.Queue( ["initFont",MathJax.OutputJax["HTML-CSS"],"NeoEulerMathJax_Variants"], ["loadComplete",MathJax.Ajax,MathJax.OutputJax["HTML-CSS"].fontDir+"/Variants/Regular/Main.js"] );
uva/mathjax-rails-assets
vendor/assets/javascripts/jax/output/HTML-CSS/fonts/Neo-Euler/Variants/Regular/Main.js
JavaScript
mit
1,809
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env bash ${IDRIS:-idris} $@ --build wrongopts.ipkg
kojiromike/Idris-dev
test/pkg010/run.sh
Shell
bsd-3-clause
62
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 24234, 1002, 1063, 8909, 6935, 1024, 1011, 8909, 6935, 1065, 1002, 1030, 1011, 1011, 3857, 3308, 7361, 3215, 1012, 12997, 2243, 2290, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.buglabs.dweetlib; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Array; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.json.JSONObject; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; import android.view.ViewParent; import com.buglabs.dweetsensorgateway.MainActivity; // // DweetLib Android // // Pre-Release version // // Created by Tim Buick on 2015-06-10. // Copyright (c) 2015 Bug Labs. All rights reserved. // public class DweetLib { // return codes public static Integer DWEET_STILL_PENDING=1; public static Integer DWEET_SUCCESS=0; public static Integer NO_NETWORK=-1; public static Integer COULD_NOT_CONNECT_TO_DWEETIO=-2; public static Integer DWEET_DID_NOT_RETURN_VALID_JSON=-3; public static Integer DWEET_JSON_FORMAT_UNEXPECTED=-4; public static Integer DWEET_RESPONSE_IS_FAILED=-5; public static Integer COULD_NOT_CONNECT_TO_LOCKED_THING=-6; public static Integer COULD_NOT_GENERATE_JSON_FROM_DATA=-7; public static Integer CONNECTION_ERROR=-8; private static DweetLib instance; HashMap<Object,Object> thingProcess; HashMap<Object,Object> thingProcessUrl; HashMap<Object,Object> thingProcessConnection; HashMap<Object,Object> thingProcessCallback; HashMap<Object,Object> thingProcessCaller; private static Context currentCtx; static { instance = new DweetLib(); } private DweetLib() { thingProcess = new HashMap<>(); thingProcessUrl = new HashMap<>(); thingProcessConnection = new HashMap<>(); thingProcessCallback = new HashMap<>(); thingProcessCaller = new HashMap<>(); } public static DweetLib getInstance(Context ctx) { currentCtx = ctx; return DweetLib.instance; } public interface DweetCallback { void callback(ArrayList<Object> ar); } public String sendDweet (JSONObject data,String thing,String key,Object caller,DweetCallback cb,boolean overwrite) { final String JSONString = data.toString(); final String urlstr = "http://dweet.io/dweet/for/" + thing; DweetTask dt = (DweetTask) thingProcess.get(urlstr); if (!isNetworkingAvailable(currentCtx)) { System.out.println("no network error"); if (caller!=null) { ArrayList ar = new ArrayList<>(); ar.add(NO_NETWORK); cb.callback(ar); } DweetTask x = (DweetTask)thingProcessUrl.get(urlstr); thingProcessUrl.remove(urlstr); thingProcess.remove(x); thingProcessConnection.remove(x); thingProcessCaller.remove(x); thingProcessCallback.remove(x); return ""; } if (dt != null) { System.out.println("still working"); if (overwrite) { System.out.println("overwriting data"); String u = (String) thingProcessUrl.get(dt); thingProcess.remove(u); HttpURLConnection c = (HttpURLConnection) thingProcessConnection.get(dt); thingProcessConnection.remove(dt); thingProcessCallback.remove(dt); thingProcessCaller.remove(dt); c.disconnect(); c = null; dt.cancel(true); thingProcessUrl.remove(dt); dt = null; } } if (dt==null) { System.out.println("starting new dt"); try { URL url = new URL(urlstr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(5000); // ms conn.setConnectTimeout(5000); // ms conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoInput(true); DweetTask x = (DweetTask) new DweetTask().execute(conn,JSONString); thingProcess.put(urlstr,x); thingProcessUrl.put(x, urlstr); thingProcessConnection.put(x, conn); if (caller!=null) thingProcessCaller.put(x,caller); if (cb!=null) thingProcessCallback.put(x,cb); System.out.println("conn:"+conn.hashCode()+", task:"+x.hashCode()); } catch (Exception e) { System.out.println("connection error"); if (caller!=null) { ArrayList ar = new ArrayList<>(); ar.add(CONNECTION_ERROR); cb.callback(ar); } DweetTask x = (DweetTask)thingProcessUrl.get(urlstr); thingProcessUrl.remove(urlstr); thingProcess.remove(x); thingProcessConnection.remove(x); thingProcessCaller.remove(x); thingProcessCallback.remove(x); } } return ""; } private class DweetTask extends AsyncTask<Object,String,Integer> { @Override protected void onPostExecute(Integer result) { super.onPostExecute(result); System.out.println(this.hashCode() + " onPostExecute:" + result); HttpURLConnection c = (HttpURLConnection) thingProcessConnection.get(this); System.out.println("post conn:" + c.hashCode()); String urlstr = (String) thingProcessUrl.get(this); thingProcess.remove(urlstr); thingProcessUrl.remove(this); thingProcessConnection.remove(this); if (thingProcessCaller.get(this)!=null) { DweetCallback dc = (DweetCallback)thingProcessCallback.get(this); ArrayList ar = new ArrayList<>(); ar.add(result); dc.callback(ar); } thingProcessCallback.remove(this); thingProcessCaller.remove(this); } @Override protected Integer doInBackground(Object...params) { System.out.println(this.hashCode() + " doInBackground"); InputStream is = null; String rsp = null; HttpURLConnection conn = (HttpURLConnection) params[0]; String JSONString = (String) params[1]; try { OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(JSONString); wr.flush(); conn.connect(); int response = conn.getResponseCode(); System.out.println(this.hashCode()+" The response is: " + response); is = conn.getInputStream(); String contentAsString = convertStreamToString(is); if (contentAsString.contentEquals("err")) { return DWEET_DID_NOT_RETURN_VALID_JSON; } System.out.println(this.hashCode() + contentAsString); } catch (IOException e) { System.out.println(this.hashCode()+" IO Exception"); return COULD_NOT_CONNECT_TO_DWEETIO; } conn.disconnect(); return DWEET_SUCCESS; } private String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line).append('\n'); } } catch (IOException e) { e.printStackTrace(); return "err"; } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); return "err"; } } return sb.toString(); } } private static boolean isNetworkingAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return (info.isAvailable() && info.isConnected()); } }
buglabs/dweet-apps
Android/DweetLib/java/com/buglabs/dweetlib/DweetLib.java
Java
mit
7,551
[ 30522, 7427, 4012, 1012, 11829, 20470, 2015, 1012, 1040, 28394, 19646, 12322, 1025, 12324, 9262, 1012, 22834, 1012, 17698, 2098, 16416, 4063, 1025, 12324, 9262, 1012, 22834, 1012, 22834, 10288, 24422, 1025, 12324, 9262, 1012, 22834, 1012, 204...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2018 Satomichi Nishihara * * 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 burai.atoms.viewer.operation.mouse; import burai.atoms.viewer.operation.ViewerEventEditorMenu; import burai.atoms.viewer.operation.ViewerEventManager; import javafx.scene.input.MouseEvent; public class MouseEventEditorMenu extends ViewerEventEditorMenu<MouseEvent> implements MouseEventKernel { private MouseEventProxy proxy; public MouseEventEditorMenu(MouseEventHandler handler) { super(); this.proxy = new MouseEventProxy(handler, this); } @Override public void perform(ViewerEventManager manager, MouseEvent event) { this.proxy.perform(manager, event); } @Override public void performOnMousePressed(MouseEvent event) { // NOP } @Override public void performOnMouseDragged(MouseEvent event) { // NOP } @Override public void performOnMouseReleased(MouseEvent event) { // NOP } }
BURAI-team/burai
src/burai/atoms/viewer/operation/mouse/MouseEventEditorMenu.java
Java
apache-2.0
1,564
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2760, 20251, 7712, 4048, 9152, 6182, 11077, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 30524, 15895, 1012, 8917, 1013, 15943, 1013, 6105, 1011, 1016, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * (C) 2003-2006 Gabest * (C) 2006-2013 see Authors.txt * * This file is part of MPC-HC. * * MPC-HC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * MPC-HC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #pragma once #include <d3dx9shader.h> class CPixelShaderCompiler { typedef HRESULT(WINAPI* D3DXCompileShaderPtr)( LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable); typedef HRESULT(WINAPI* D3DXDisassembleShaderPtr)( CONST DWORD* pShader, bool EnableColorCode, LPCSTR pComments, LPD3DXBUFFER* ppDisassembly); D3DXCompileShaderPtr m_pD3DXCompileShader; D3DXDisassembleShaderPtr m_pD3DXDisassembleShader; CComPtr<IDirect3DDevice9> m_pD3DDev; public: CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent = false); virtual ~CPixelShaderCompiler(); HRESULT CompileShader( LPCSTR pSrcData, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, IDirect3DPixelShader9** ppPixelShader, CString* disasm = nullptr, CString* errmsg = nullptr); };
jeeb/mpc-hc
src/filters/renderer/VideoRenderers/PixelShaderCompiler.h
C
gpl-3.0
1,932
[ 30522, 1013, 1008, 1008, 1006, 1039, 1007, 2494, 1011, 2294, 12900, 3367, 1008, 1006, 1039, 1007, 2294, 1011, 2286, 2156, 6048, 1012, 19067, 2102, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 6131, 2278, 1011, 16731, 1012, 1008, 1008, 6131, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * SonarQube, open source software quality management tool. * Copyright (C) 2008-2014 SonarSource * mailto:contact AT sonarsource DOT com * * SonarQube is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * SonarQube is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.sonar.server.usergroups.ws; import org.sonar.server.ws.WsAction; public interface UserGroupsWsAction extends WsAction { // Marker interface }
jblievremont/sonarqube
server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UserGroupsWsAction.java
Java
lgpl-3.0
1,043
[ 30522, 1013, 1008, 1008, 24609, 28940, 4783, 1010, 2330, 3120, 4007, 3737, 2968, 6994, 1012, 1008, 9385, 1006, 1039, 1007, 2263, 1011, 2297, 24609, 6499, 3126, 3401, 1008, 5653, 3406, 1024, 3967, 2012, 24609, 6499, 3126, 3401, 11089, 4012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import {Component} from '@angular/core'; @Component({ selector: 'not-found', templateUrl: 'app/404.component/404.component.html', styleUrls: ['app/404.component/404.component.css'], }) export class NotFoundComponent {}
Nandtel/spring-boot-angular2-starter
src/main/javascript/app/404.component/404.component.ts
TypeScript
mit
231
[ 30522, 12324, 1063, 6922, 1065, 2013, 1005, 1030, 16108, 1013, 4563, 1005, 1025, 1030, 6922, 1006, 1063, 27000, 1024, 1005, 2025, 1011, 2179, 1005, 1010, 23561, 3126, 2140, 1024, 1005, 10439, 1013, 24837, 1012, 6922, 1013, 24837, 1012, 6922...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "subfind.hh" namespace tao { namespace subfind { void make_hdf5_types( h5::datatype& mem_type, h5::datatype& file_type ) { // Create memory type. mem_type.compound( sizeof(halo) ); mem_type.insert( h5::datatype::native_int, "descendant", HOFFSET( halo, descendant ) ); mem_type.insert( h5::datatype::native_int, "first progenitor", HOFFSET( halo, first_progenitor ) ); mem_type.insert( h5::datatype::native_int, "next progenitor", HOFFSET( halo, next_progenitor ) ); mem_type.insert( h5::datatype::native_int, "first friend-of-friend", HOFFSET( halo, first_fof ) ); mem_type.insert( h5::datatype::native_int, "next friend-of-friend", HOFFSET( halo, next_fof ) ); mem_type.insert( h5::datatype::native_int, "number of particles", HOFFSET( halo, num_particles ) ); mem_type.insert( h5::datatype::native_float, "mass, mean 200", HOFFSET( halo, m_mean200 ) ); mem_type.insert( h5::datatype::native_float, "virial mass", HOFFSET( halo, mvir ) ); mem_type.insert( h5::datatype::native_float, "mass, top hat", HOFFSET( halo, m_top_hat ) ); mem_type.insert( h5::datatype::native_float, "x position", HOFFSET( halo, x ) ); mem_type.insert( h5::datatype::native_float, "y position", HOFFSET( halo, y ) ); mem_type.insert( h5::datatype::native_float, "z position", HOFFSET( halo, z ) ); mem_type.insert( h5::datatype::native_float, "x velocity", HOFFSET( halo, vx ) ); mem_type.insert( h5::datatype::native_float, "y velocity", HOFFSET( halo, vy ) ); mem_type.insert( h5::datatype::native_float, "z velocity", HOFFSET( halo, vz ) ); mem_type.insert( h5::datatype::native_float, "velocity dispersion (?)", HOFFSET( halo, vel_disp ) ); mem_type.insert( h5::datatype::native_float, "maximum velocity", HOFFSET( halo, vmax ) ); mem_type.insert( h5::datatype::native_float, "x spin", HOFFSET( halo, sx ) ); mem_type.insert( h5::datatype::native_float, "y spin", HOFFSET( halo, sy ) ); mem_type.insert( h5::datatype::native_float, "z spin", HOFFSET( halo, sz ) ); mem_type.insert( h5::datatype::native_llong, "most bound ID", HOFFSET( halo, most_bound_id ) ); mem_type.insert( h5::datatype::native_int, "snapshot", HOFFSET( halo, snap_num ) ); mem_type.insert( h5::datatype::native_int, "file number", HOFFSET( halo, file_nr ) ); mem_type.insert( h5::datatype::native_int, "subhalo index", HOFFSET( halo, subhalo_index ) ); mem_type.insert( h5::datatype::native_int, "subhalo half-mass", HOFFSET( halo, sub_half_mass ) ); // Create file type. file_type.compound( 104 ); file_type.insert( h5::datatype::std_i32be, "descendant", 0 ); file_type.insert( h5::datatype::std_i32be, "first progenitor", 4 ); file_type.insert( h5::datatype::std_i32be, "next progenitor", 8 ); file_type.insert( h5::datatype::std_i32be, "first friend-of-friend", 12 ); file_type.insert( h5::datatype::std_i32be, "next friend-of-friend", 16 ); file_type.insert( h5::datatype::std_i32be, "number of particles", 20 ); file_type.insert( h5::datatype::ieee_f32be, "mass, mean 200", 24 ); file_type.insert( h5::datatype::ieee_f32be, "virial mass", 28 ); file_type.insert( h5::datatype::ieee_f32be, "mass, top hat", 32 ); file_type.insert( h5::datatype::ieee_f32be, "x position", 36 ); file_type.insert( h5::datatype::ieee_f32be, "y position", 40 ); file_type.insert( h5::datatype::ieee_f32be, "z position", 44 ); file_type.insert( h5::datatype::ieee_f32be, "x velocity", 48 ); file_type.insert( h5::datatype::ieee_f32be, "y velocity", 52 ); file_type.insert( h5::datatype::ieee_f32be, "z velocity", 56 ); file_type.insert( h5::datatype::ieee_f32be, "velocity dispersion (?)", 60 ); file_type.insert( h5::datatype::ieee_f32be, "maximum velocity", 64 ); file_type.insert( h5::datatype::ieee_f32be, "x spin", 68 ); file_type.insert( h5::datatype::ieee_f32be, "y spin", 72 ); file_type.insert( h5::datatype::ieee_f32be, "z spin", 76 ); file_type.insert( h5::datatype::std_i64be, "most bound ID", 80 ); file_type.insert( h5::datatype::std_i32be, "snapshot", 88 ); file_type.insert( h5::datatype::std_i32be, "file number", 92 ); file_type.insert( h5::datatype::std_i32be, "subhalo index", 96 ); file_type.insert( h5::datatype::std_i32be, "subhalo half-mass", 100 ); } } }
IntersectAustralia/asvo-tao
science_modules/base/src/subfind.cc
C++
gpl-3.0
4,276
[ 30522, 1001, 2421, 1000, 4942, 16294, 2094, 1012, 1044, 2232, 1000, 3415, 15327, 20216, 1063, 3415, 15327, 4942, 16294, 2094, 1063, 11675, 2191, 1035, 10751, 2546, 2629, 1035, 4127, 1006, 1044, 2629, 1024, 1024, 2951, 13874, 1004, 2033, 221...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php $path = '/home3/johangau/orcapilot'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'framework_0_2/_include.inc'; $session = new Session(); $pa = new PilotArray(); $pa->loadOperationPilots($_GET['operation']); include 'framework_0_2/_header.php'; ?> <h3>Make a payment</h3> <p>select from the list</p> <p><form action="singleoperation.php"><?php $pa->getHTMLdropdown(); ?> <input type="text" class="dark" name="amount"><br> <input class="button" type="image" width="88" height="19" border="0" src="images/paypilot.png" /> <input type="hidden" name="operation" value="<?php if(isset($_GET['operation']))echo $_GET['operation'];?>" /> <input type="hidden" name="makepayment" value="yes" /> <input type="hidden" name="session" value="<?php echo $session->getSessionHash();?>"> <input type="hidden" name="verification" value="<?php echo Payment::getNewVerificationCode();?>"> </form></p> <p>Or add a new pilot/user</p>
johangau/Orca-Pilot
public_html/app/paypilot.php
PHP
mit
965
[ 30522, 1026, 1029, 25718, 1002, 4130, 1027, 1005, 1013, 2188, 2509, 1013, 13093, 20420, 1013, 2030, 17695, 22360, 2102, 1005, 1025, 2275, 1035, 2421, 1035, 4130, 1006, 2131, 1035, 2421, 1035, 4130, 1006, 1007, 1012, 4130, 1035, 19802, 25879...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
""" Test how many times newly loaded binaries are notified; they should be delivered in batches instead of one-by-one. """ from __future__ import print_function import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class ModuleLoadedNotifysTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True # DynamicLoaderDarwin should batch up notifications about # newly added/removed libraries. Other DynamicLoaders may # not be written this way. @skipUnlessDarwin def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). self.line = line_number('main.cpp', '// breakpoint') def test_launch_notifications(self): """Test that lldb broadcasts newly loaded libraries in batches.""" self.build() exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(False) listener = self.dbg.GetListener() listener.StartListeningForEventClass( self.dbg, lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitModulesLoaded | lldb.SBTarget.eBroadcastBitModulesUnloaded) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # break on main breakpoint = target.BreakpointCreateByName('main', 'a.out') event = lldb.SBEvent() # CreateTarget() generated modules-loaded events; consume them & toss while listener.GetNextEvent(event): True error = lldb.SBError() flags = target.GetLaunchInfo().GetLaunchFlags() process = target.Launch(listener, None, # argv None, # envp None, # stdin_path None, # stdout_path None, # stderr_path None, # working directory flags, # launch flags False, # Stop at entry error) # error self.assertTrue( process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) total_solibs_added = 0 total_solibs_removed = 0 total_modules_added_events = 0 total_modules_removed_events = 0 while listener.GetNextEvent(event): if lldb.SBTarget.EventIsTargetEvent(event): if event.GetType() == lldb.SBTarget.eBroadcastBitModulesLoaded: solib_count = lldb.SBTarget.GetNumModulesFromEvent(event) total_modules_added_events += 1 total_solibs_added += solib_count if self.TraceOn(): # print all of the binaries that have been added added_files = [] i = 0 while i < solib_count: module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, event) added_files.append(module.GetFileSpec().GetFilename()) i = i + 1 print("Loaded files: %s" % (', '.join(added_files))) if event.GetType() == lldb.SBTarget.eBroadcastBitModulesUnloaded: solib_count = lldb.SBTarget.GetNumModulesFromEvent(event) total_modules_removed_events += 1 total_solibs_removed += solib_count if self.TraceOn(): # print all of the binaries that have been removed removed_files = [] i = 0 while i < solib_count: module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, event) removed_files.append(module.GetFileSpec().GetFilename()) i = i + 1 print("Unloaded files: %s" % (', '.join(removed_files))) # This is testing that we get back a small number of events with the loaded # binaries in batches. Check that we got back more than 1 solib per event. # In practice on Darwin today, we get back two events for a do-nothing c # program: a.out and dyld, and then all the rest of the system libraries. avg_solibs_added_per_event = int(float(total_solibs_added) / float(total_modules_added_events)) self.assertGreater(avg_solibs_added_per_event, 1)
google/llvm-propeller
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
Python
apache-2.0
4,739
[ 30522, 1000, 1000, 1000, 3231, 2129, 2116, 2335, 4397, 8209, 8026, 12086, 2024, 19488, 1025, 2027, 2323, 2022, 5359, 1999, 14108, 2229, 2612, 1997, 2028, 1011, 2011, 1011, 2028, 1012, 1000, 1000, 1000, 2013, 1035, 1035, 2925, 1035, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class Browser ## # User agent string. attr_reader :user_agent ## # Initialize with user agent _user_agent_. def initialize user_agent @user_agent = user_agent.strip end ## # Return name for user agent _user_agent_. def self.name user_agent case user_agent when /ABrowse/i ; :ABrowse when /AbiLogicBot/i ; :AbiLogicBot # Link Checker when /Acoo/i ; :'Acoo Browser' when /Advanced/i ; :Advanced when /America Online/i ; :'America Online Browser' when /Amaya/i ; :Amaya when /Amiga[\/ ]/i ; :Amiga when /AmigaVoyager/i ; :AmigaVoyager when /Android/i ; :Android when /AOL/i ; :AOL when /Aplix/i ; :Aplix when /Arora/i ; :Arora when /Avant/i ; :Avant when /Beonex/i ; :Beonex when /BlackBerry/i ; :BlackBerry when /Bloglines/i ; :Bloglines # Feed Reader when /BonEcho/i ; :BonEcho when /Camino/i ; :Camino when /Charon/i ; :Charon when /Cheshire/i ; :Cheshire when /Chimera/i ; :Chimera when /Chrome[\/ ]/i ; :Chrome when /ChromePlus/i ; :ChromePlus when /CometBird/i ; :CometBird when /Crazy/i ; :Crazy when /CSE HTML Validator/i ; :'CSE HTML Validator' # Validator when /CSSCheck/i ; :CSSCheck # Validator when /Cyberdog/i ; :Cyberdog when /Cynthia/i ; :Cynthia # Validator when /Deepnet/i ; :Deepnet when /DeskBrowse/i ; :DeskBrowse when /DOCOMO/i ; :DOCOMO #Embedded Mobile Based when /Dillo/i ; :Dillo when /Elinks/i ; :Elinks when /Enigma/i ; :Enigma when /Epiphany/i ; :Epiphany when /Everyfeed-spider/i ; :'Everyfeed-spider' # Feed Reader when /FeedFetcher-Google/i ; :'FeedFetcher-Google' # Feed Reader when /Fennec/i ; :Fennec when /Firebird/i ; :Firebird when /Firefox[\/ ]/i ; :Firefox when /Flock/i ; :Flock when /Fluid/i ; :Fluid when /Galaxy/i ; :Galaxy when /Galeon/i ; :Galeon when /Genius/i ; :Genius when /GranParadiso/i ; :GranParadiso when /Green/i ; :Green when /Gregarius/i ; :Gregarius # Feed Reader when /HTMLParser/i ; :HTMLParser # Validator when /Hana/i ; :Hana when /HotJava/i ; :HotJava when /IBM WebExplorer/i ; :'IBM WebExplorer' when /IBrowse/i ; :IBrowse when /iCab/i ; :iCab when /Iceape/i ; :Iceape when /IceCat/i ; :IceCat when /Iceweasel/i ; :Iceweasel when /iNet/i ; :iNet when /iPad/i ; :iPad when /iPhone/i ; :iPhone #Embedded Mobile Based when /Iron/i ; :Iron when /Java/i ; :Java # Library when /K-Meleon/i ; :'K-Meleon' when /K-Ninja/i ; :'K-Ninja' when /Kapiko/i ; :Kapiko when /Kazehakase/i ; :Kazehakase when /KKman/i ; :KKman when /klondike/i ; :Klondike when /KMLite/i ; :KMLite when /Konqueror/i ; :Konqueror when /LeechCraft/i ; :LeechCraft when /Link Valet/i ; :'Link Valet' # Link Checker when /Link Validity Check/i ; :'Link Validity Check' # Link Checker when /LinksManager.com_bot/i ; :'LinksManager.com_bot' # Link Checker when /Links/i ; :Links when /libwww-perl/i ; :'libwww-perl' # Library when /Lobo/i ; :Lobo when /Lolifox/i ; :Lolifox when /Lunascape/i ; :Lunascape when /Lynx/i ; :Lynx when /Madfox/i ; :Madfox when /Maxthon/i ; :Maxthon when /Midori/i ; :Midori when /Minefield/i ; :Minefield when /Minimo/i ; :Minimo when /Mojoo Robot/i ; :'Mojoo Robot' # Link Checker when /MSIE[\/ ]/i ; :IE #Common when /MultiZilla/i ; :MultiZilla when /MyIE2/i ; :MyIE2 when /Namoroka/i ; :Namoroka when /NCSA/i ; :NCSA_Mosaic when /NetFront/i ; :NetFront when /NetNewsWire/i ; :NetNewsWire when /NetPositive/i ; :NetPositive when /Netscape/i ; :Netscape when /NetSurf/i ; :NetSurf when /Notifixious/i ; :Notifixious # Link Validator when /Offline Explorer/i ; :'Offline Explorer' # Offline Browser when /OmniWeb/i ; :OmniWeb when /Online link validator/i; :'Online link validator' # Link Validator when /Openwave/i ; :OpenWave when /Opera Mini/i ; :'Opera Mini' #Embedded Mobile Based when /Opera Mobi/i ; :'Opera Mobile' #Embedded Mobile Based when /Opera[\/ ]/i ; :Opera #Common when /Orca/i ; :Orca when /Oregano/i ; :Oregano when /P3P Validator/i ; :'P3P Validator' # Validator when /Palm/i ; :Palm when /Peach/i ; :Peach # Library when /Playstation 3/i ; :PS3 # Console when /Playstation portable/i ; :PSP # Console when /Phoenix/i ; :Phoenix when /Pogo/i ; :Pogo when /Python-urllib/i ; :'Python-urllib' # Library when /QtWeb/i ; :QtWeb when /Reciprocal Link/i ; :'Reciprocal Link' # Link Checker when /REL Link Checker Lite/i; :'REL Link Checker Lite' # Link Checker when /retawq/i ; :Retawq when /reqwirelessweb/i ; :Reqwirelessweb when /Safari[\/ ]/i ; :Safari when /SeaMonkey/i ; :SeaMonkey when /Shiira/i ; :Shiira when /Shiretoko/i ; :Shiretoko when /SiteBar/i ; :SiteBar #Link Checker when /Skyfire/i ; :Skyfire when /Sleipnir/i ; :Sleipnir when /Stainless/i ; :Stainless when /Sunrise/i ; :Sunrise when /SuperBot/i ; :SuperBot # Offline Browser when /SymbianOS/i ; :SymbianOS #Embedded Mobile Based when /Symbian/i ; :Symbian #Embedded Mobile Based when /TeaShark/i ; :TeaShark when /Thunderbird/i ; :Thunderbird # E-Mail Client when /UCWEB/i ; :UCWEB when /uzbl/i ; :Uzbl when /Vivante Link Checker/i ; :'Vivante Link Checker' # Link Checker when /w3m/i ; :w3m #when /W3C-checklink/i ; :'W3C-checklink' # Link Checker #when /W3C_CSS_Validator_JFouffa/i ; :W3C_CSS_Validator_JFouffa # Validator #when /W3C_Validator/i ; :W3C_Validator # Validator when /WapTiger/i ; :WapTiger #Embedded Mobile Based when /WDG_Validator/i ; :WDG_Validator # Validator when /Web Downloader/i ; :'Web Downloader' # Offline Browser when /WebCopier/i ; :WebCopier # Offline Browser when /webOS/i ; :Palm when /WebZIP/i ; :WebZIP # Offline Browser when /Wget/i ; :Wget # Offline Browser when /Winwap/i ; :Winwap #Embedded Mobile Based when /Wii/i ; :Wii # Console when /WorldWideWeb/i ; :WorldWideWeb when /Wyzo/i ; :Wyzo when /Xenu Link Sleuth/i ; :'Xenu Link Sleuth' # Link Checker when /Mozilla/i ; :Mozilla #Common else ; :Unknown end end ## # Return version for user agent _user_agent_. def self.version user_agent name = name user_agent case name when :Chrome ; $1 if user_agent =~ /chrome\/([\d\w\.\-]+)/i when :Safari ; if user_agent =~ /version\/([\d\w\.\-]+)/i $1 elsif user_agent =~ /Safari([0-9\.\-]+)/i $1 else user_agent =~ /Safari\/([0-9\.\-]+)/i $1 end when :PS3 ; $1 if user_agent =~ /([\d\w\.\-]+)\)\s*$/i when :PSP ; $1 if user_agent =~ /([\d\w\.\-]+)\)?\s*$/i # when :SymbianOS ; $1 if user_agent =~ /\/([\d\w\.\-]+)/i #\)?\s*$ # when :Symbian ; $1 if user_agent =~ /\ ([0-9\d\w\.\-]+)\)?\s*$/i # when :iPhone ; $1 if user_agent =~ /([\d\w\.\-]+)\)?\s*$/i when :iPhone ; $1 if user_agent =~ /#{name.to_s} OS ([0-9\-\.\_]+)/i #when name[/safari([0-9\-\.\_]+)/i] ; $1 if name =~ /([0-9\-\.\_]+)/i else $1 if user_agent =~ /#{name.to_s}[\/ ]([\d\w\.\-]+)/i end end ## # Is _string_. Device def self.is_browser? user_agent, browser browser_sym = name user_agent browser_sym = browser_sym.to_s.downcase browser = browser.to_s.downcase browser_sym.include? browser end end
shenoudab/active_device
lib/active_device/browser.rb
Ruby
mit
9,382
[ 30522, 2465, 16602, 1001, 1001, 1001, 5310, 4005, 5164, 1012, 2012, 16344, 1035, 8068, 1024, 5310, 1035, 4005, 1001, 1001, 1001, 3988, 4697, 2007, 5310, 4005, 1035, 5310, 1035, 4005, 1035, 1012, 13366, 3988, 4697, 5310, 1035, 4005, 1030, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package net.prank.core; import net.prank.example.ExampleObject; import net.prank.example.ExampleScoreCard; import org.junit.Test; import java.math.BigDecimal; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; /** * * @author dmillett * * Copyright 2012 David Millett * 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. */ public class PranksterTest { private static final double DELTA = 1e-10; @Test public void test__execute() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 2, 4.0, 50.0); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); RequestOptions options = new RequestOptions.RequestOptionsBuilder().build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); optionsMap.put(exampleScoreCard.getName(), options); Request<ExampleObject> exampleRequest = new Request<>(exampleObject, optionsMap); Set<Future<Result>> futureResult = prankster.setupScoring(exampleRequest); for (Future<Result> future : futureResult) { try { // Should return quickly, they were already submitted to the pool future.get(50,TimeUnit.MILLISECONDS); } catch (Exception e) { fail("Should not"); } } assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(new BigDecimal("5"), result.getScoreData().getScore()); assertEquals(2, result.getPosition().getOriginalIndex()); assertEquals(9.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(50.0, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__execute_updateObjectsWithScores() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 2, 4.0, 50.0); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); RequestOptions options = new RequestOptions.RequestOptionsBuilder().build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); optionsMap.put(exampleScoreCard.getName(), options); Request<ExampleObject> exampleRequest = new Request<>(exampleObject, optionsMap); Set<Prankster.ScoringFuture> futureResult = prankster.buildScoringUpdateFutures(exampleRequest, 50); for (Prankster.ScoringFuture scoringFuture : futureResult) { try { // Should return quickly, they were already submitted to the pool scoringFuture.getFuture().get(50, TimeUnit.MILLISECONDS); } catch (Exception e) { fail("Should not"); } } assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(new BigDecimal("5"), result.getScoreData().getScore()); assertEquals(2, result.getPosition().getOriginalIndex()); assertEquals(9.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(50.0, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__updateObjectScore() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 2, 4.0, 50.0); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); Request<ExampleObject> exampleRequest = new Request<>(exampleObject); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(5.0, result.getScoreData().getScore() .doubleValue(), DELTA); assertEquals(2, result.getPosition().getOriginalIndex()); assertEquals(9.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(50.0, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__updateObjectsWithScores() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 2, 4.0, 50.0); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); Request<ExampleObject> exampleRequest = new Request<>(exampleObject); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(5.0, result.getScoreData().getScore() .doubleValue(), DELTA); assertEquals(2, result.getPosition().getOriginalIndex()); assertEquals(9.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(50.0, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__execute_disabled() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); RequestOptions options = new RequestOptions.RequestOptionsBuilder().setEnabledB(false).build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); optionsMap.put(exampleScoreCard.getName(), options); Request<ExampleObject> exampleRequest = new Request<>(exampleObject, optionsMap); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(0, exampleObject.getScoreSummary().getResults().size()); } @Test public void test__execute_disabled_updateObjectsWithScores() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); RequestOptions options = new RequestOptions.RequestOptionsBuilder().setEnabledB(false).build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); optionsMap.put(exampleScoreCard.getName(), options); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("50.00")); Request<ExampleObject> exampleRequest = new Request<ExampleObject>(exampleObject, optionsMap); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(0, exampleObject.getScoreSummary().getResults().size()); } @Test public void test__execute_enabled() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("55.00")); Request<ExampleObject> exampleRequest = new Request<>(exampleObject); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(5.0, result.getScoreData().getScore().doubleValue(), DELTA); assertEquals(4, result.getPosition().getOriginalIndex()); assertEquals(10.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(0.75, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__execute_enabled_updateObjectsWithScores() { ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); ExampleObject exampleObject = new ExampleObject(3, new BigDecimal("5.00"), new BigDecimal("55.00")); Request<ExampleObject> exampleRequest = new Request<>(exampleObject); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); prankster.updateObjectsWithScores(exampleRequest, 50); assertEquals(1, exampleObject.getScoreSummary().getResults().size()); Result result = exampleObject.getScoreSummary().getResultByScoreCard(exampleScoreCard.getName()); assertNotNull(result); assertEquals(5.0, result.getScoreData().getScore().doubleValue(), DELTA); assertEquals(4, result.getPosition().getOriginalIndex()); assertEquals(10.0, result.getStatistics().getAverage().doubleValue(), DELTA); assertEquals(0.75, result.getStatistics().getStandardDeviation().doubleValue(), DELTA); } @Test public void test__determineTimeout_default() { long defaultTimeout = 10; ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); long timeoutNull = prankster.determineTimeout(defaultTimeout, exampleScoreCard.getName(), null); assertEquals(10, timeoutNull); Map<String, RequestOptions> optionsMap = new HashMap<>(); long timeoutEmpty = prankster.determineTimeout(defaultTimeout, exampleScoreCard.getName(), optionsMap); assertEquals(10, timeoutEmpty); } @Test public void test__determineTimeout_per_request() { long defaultTimeout = 10; RequestOptions options = new RequestOptions.RequestOptionsBuilder().setTimeoutMillisB(1).build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); optionsMap.put(exampleScoreCard.getName(), options); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); long timeout = prankster.determineTimeout(defaultTimeout, exampleScoreCard.getName(), optionsMap); assertEquals(1, timeout); } @Test public void test__determineTimeout_per_request_disabled() { long defaultTimeout = 10; RequestOptions options = new RequestOptions.RequestOptionsBuilder().setTimeoutMillisB(1).setEnabledB(false).build(); Map<String, RequestOptions> optionsMap = new HashMap<>(); ScoreCard<ExampleObject> exampleScoreCard = new ExampleScoreCard(2, 4, 5.0, 0.75); optionsMap.put(exampleScoreCard.getName(), options); Prankster<ExampleObject> prankster = buildPrankster(exampleScoreCard); long timeout = prankster.determineTimeout(defaultTimeout, exampleScoreCard.getName(), optionsMap); assertEquals(10, timeout); } private Prankster<ExampleObject> buildPrankster(ScoreCard... scoreCard) { Set<ScoreCard<ExampleObject>> scoreCards = new HashSet<>(); for (ScoreCard card : scoreCard) { scoreCards.add(card); } return new Prankster<>(scoreCards, 1); } }
dmillett/prank
src/test/java/net/prank/core/PranksterTest.java
Java
apache-2.0
12,515
[ 30522, 7427, 5658, 1012, 26418, 1012, 4563, 1025, 12324, 5658, 1012, 26418, 1012, 2742, 1012, 2742, 16429, 20614, 1025, 12324, 5658, 1012, 26418, 1012, 2742, 1012, 4973, 17345, 11522, 1025, 12324, 8917, 1012, 12022, 4183, 1012, 3231, 1025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright Andrey Semashev 2018. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) */ /*! * \file allocator_traits.hpp * \author Andrey Semashev * \date 03.01.2018 * * \brief This header is the Boost.Log library implementation, see the library documentation * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. */ #ifndef BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_ #define BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_ #include <memory> #include <boost/log/detail/config.hpp> #if defined(BOOST_NO_CXX11_ALLOCATOR) #include <boost/container/allocator_traits.hpp> #endif #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { BOOST_LOG_OPEN_NAMESPACE namespace aux { // A portable name for allocator traits #if !defined(BOOST_NO_CXX11_ALLOCATOR) using std::allocator_traits; #else using boost::container::allocator_traits; #endif /*! * \brief A standalone trait to rebind an allocator to another type. * * The important difference from <tt>std::allocator_traits&lt;Alloc&gt;::rebind_alloc&lt;U&gt;</tt> is that this * trait does not require template aliases and thus is compatible with C++03. There is * <tt>boost::container::allocator_traits&lt;Alloc&gt;::portable_rebind_alloc&lt;U&gt;</tt>, but it is not present in <tt>std::allocator_traits</tt>. * It will also attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template. We don't want * that to happen because it prohibits using <tt>std::allocator&lt;void&gt;</tt> in C++17 and later, which deprecated * this allocator specialization. This standalone trait does not use the nested <tt>rebind</tt> template in this case. */ template< typename Allocator, typename U > struct rebind_alloc { #if !defined(BOOST_NO_CXX11_ALLOCATOR) typedef typename std::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE rebind_alloc< U > type; #else typedef typename boost::container::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE portable_rebind_alloc< U >::type type; #endif }; template< typename U > struct rebind_alloc< std::allocator< void >, U > { typedef std::allocator< U > type; }; } // namespace aux BOOST_LOG_CLOSE_NAMESPACE // namespace log } // namespace boost #include <boost/log/detail/footer.hpp> #endif // BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
Owldream/Ginseng
include/ginseng/3rd-party/boost/log/detail/allocator_traits.hpp
C++
apache-2.0
2,580
[ 30522, 1013, 1008, 1008, 9385, 29219, 7367, 9335, 5369, 2615, 2760, 1012, 1008, 5500, 2104, 1996, 12992, 4007, 6105, 1010, 2544, 1015, 1012, 1014, 1012, 1008, 1006, 2156, 10860, 5371, 6105, 1035, 1015, 1035, 1014, 1012, 19067, 2102, 2030, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class Mp3unicode < Formula desc "Command-line utility to convert mp3 tags between different encodings" homepage "http://mp3unicode.sourceforge.net/" url "https://github.com/downloads/alonbl/mp3unicode/mp3unicode-1.2.1.tar.bz2" sha256 "375b432ce784407e74fceb055d115bf83b1bd04a83b95256171e1a36e00cfe07" head "https://github.com/alonbl/mp3unicode.git" bottle do cellar :any sha256 "e9db3c9529d5358f83bb67d5966c6b508851f27a3bc61d5212b674d620a03a7e" => :el_capitan sha256 "56c77d872d7adda53f68661145a5b372ecf64ef0284181a7ecd9b56997f14c74" => :yosemite sha256 "10d647d04714f9e95d9bf3ab8dfd023fea3f22876dfe055c01211e527a2facd3" => :mavericks end depends_on "pkg-config" => :build depends_on "taglib" if build.head? depends_on "autoconf" => :build depends_on "automake" => :build end def install ENV.append "ICONV_LIBS", "-liconv" system "autoreconf", "-i" if build.head? system "./configure", "--prefix=#{prefix}" system "make", "install" end test do system "#{bin}/mp3unicode", "-s", "ASCII", "-w", test_fixtures("test.mp3") end end
zhipeng-jia/homebrew
Library/Formula/mp3unicode.rb
Ruby
bsd-2-clause
1,108
[ 30522, 2465, 23378, 19496, 16044, 1026, 5675, 4078, 2278, 1000, 3094, 1011, 2240, 9710, 2000, 10463, 23378, 22073, 2090, 2367, 17181, 2015, 1000, 2188, 13704, 1000, 8299, 1024, 1013, 1013, 23378, 19496, 16044, 1012, 3120, 29278, 3351, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests\TicketFormRequest; use App\Ticket; use Illuminate\Support\Facades\Mail; class TicketsController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $tickets = Ticket::all(); //compact devuelve un array de tickets return view('tickets.index', compact('tickets')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('tickets.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ //TicketFormRequest obligamos a que valide los campos del formulario public function store(TicketFormRequest $request) { $slug = uniqid(); $ticket = new Ticket(array( 'title' => $request->get('title'), 'content' => $request->get('content'), 'slug' => $slug )); $ticket->save(); $data = array( 'ticket' => $slug, ); Mail::send('emails.ticket', $data, function ($message) { $message->from('javimartinalonso@gmail.com', 'Curso Laravel'); $message->to('javimartinalonso@gmail.com')->subject('¡Hay un nuevo ticket!'); }); return redirect('/contact')-> with('status', 'Su Ticket ha sido creado. Su id única es: ' .$slug); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($slug) { $ticket = Ticket::whereSlug($slug)->firstOrFail(); $comments = $ticket->comments()->get(); return view('tickets.show', compact('ticket', 'comments')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($slug) { $ticket = Ticket::whereSlug($slug)->firstOrFail(); return view('tickets.edit', compact('ticket')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($slug, TicketFormRequest $request) { $ticket = Ticket::whereSlug($slug)->firstOrFail(); $ticket->title = $request->get('title'); $ticket->content = $request->get('content'); if($request->get('status') != null) { $ticket->status = 0; } else { $ticket->status = 1; } $ticket->save(); return redirect(action('TicketsController@edit', $ticket->slug))->with('status', '¡El ticket '.$slug.' ha sido actualizado!'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($slug) { $ticket = Ticket::whereSlug($slug)->firstOrFail(); $ticket->delete(); return redirect('/tickets')->with('status', 'El ticket '.$slug.' ha sido borrado'); } }
javiermartinalonso/LARAVEL5
Laravel/app/Http/Controllers/TicketsController.php
PHP
mit
3,359
[ 30522, 1026, 1029, 25718, 3415, 15327, 10439, 1032, 8299, 1032, 21257, 1025, 2224, 5665, 12717, 12556, 1032, 8299, 1032, 5227, 1025, 2224, 10439, 1032, 8299, 1032, 11186, 1032, 7281, 14192, 2890, 15500, 1025, 2224, 10439, 1032, 7281, 1025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
-- DELETE FROM `creature_addon` WHERE `guid` IN (28786, 28800, 28798);
RichTee/TrinityCore
sql/updates/world/2015_04_17_01_world_2015_03_28_00.sql
SQL
gpl-2.0
71
[ 30522, 1011, 1011, 3972, 12870, 2013, 1036, 6492, 1035, 5587, 2239, 1036, 2073, 1036, 26458, 2094, 1036, 1999, 1006, 23090, 20842, 1010, 24841, 8889, 1010, 23090, 2683, 2620, 1007, 1025, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import _ = require("../index"); // tslint:disable-next-line:strict-export-declare-modifiers type GlobalPartial<T> = Partial<T>; declare module "../index" { type PartialObject<T> = GlobalPartial<T>; type Many<T> = T | ReadonlyArray<T>; interface LoDashStatic { /** * Creates a lodash object which wraps value to enable implicit method chain sequences. * Methods that operate on and return arrays, collections, and functions can be chained together. * Methods that retrieve a single value or may return a primitive value will automatically end the * chain sequence and return the unwrapped value. Otherwise, the value must be unwrapped with value(). * * Explicit chain sequences, which must be unwrapped with value(), may be enabled using _.chain. * * The execution of chained methods is lazy, that is, it's deferred until value() is * implicitly or explicitly called. * * Lazy evaluation allows several methods to support shortcut fusion. Shortcut fusion * is an optimization to merge iteratee calls; this avoids the creation of intermediate * arrays and can greatly reduce the number of iteratee executions. Sections of a chain * sequence qualify for shortcut fusion if the section is applied to an array and iteratees * accept only one argument. The heuristic for whether a section qualifies for shortcut * fusion is subject to change. * * Chaining is supported in custom builds as long as the value() method is directly or * indirectly included in the build. * * In addition to lodash methods, wrappers have Array and String methods. * The wrapper Array methods are: * concat, join, pop, push, shift, sort, splice, and unshift. * The wrapper String methods are: * replace and split. * * The wrapper methods that support shortcut fusion are: * at, compact, drop, dropRight, dropWhile, filter, find, findLast, head, initial, last, * map, reject, reverse, slice, tail, take, takeRight, takeRightWhile, takeWhile, and toArray * * The chainable wrapper methods are: * after, ary, assign, assignIn, assignInWith, assignWith, at, before, bind, bindAll, bindKey, * castArray, chain, chunk, commit, compact, concat, conforms, constant, countBy, create, * curry, debounce, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, * drop, dropRight, dropRightWhile, dropWhile, extend, extendWith, fill, filter, flatMap, * flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, flow, flowRight, * fromPairs, functions, functionsIn, groupBy, initial, intersection, intersectionBy, intersectionWith, * invert, invertBy, invokeMap, iteratee, keyBy, keys, keysIn, map, mapKeys, mapValues, * matches, matchesProperty, memoize, merge, mergeWith, method, methodOf, mixin, negate, * nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, partial, partialRight, * partition, pick, pickBy, plant, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, * push, range, rangeRight, rearg, reject, remove, rest, reverse, sampleSize, set, setWith, * shuffle, slice, sort, sortBy, sortedUniq, sortedUniqBy, splice, spread, tail, take, * takeRight, takeRightWhile, takeWhile, tap, throttle, thru, toArray, toPairs, toPairsIn, * toPath, toPlainObject, transform, unary, union, unionBy, unionWith, uniq, uniqBy, uniqWith, * unset, unshift, unzip, unzipWith, update, updateWith, values, valuesIn, without, wrap, * xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, and zipWith. * * The wrapper methods that are not chainable by default are: * add, attempt, camelCase, capitalize, ceil, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, * conformsTo, deburr, defaultTo, divide, each, eachRight, endsWith, eq, escape, escapeRegExp, * every, find, findIndex, findKey, findLast, findLastIndex, findLastKey, first, floor, forEach, * forEachRight, forIn, forInRight, forOwn, forOwnRight, get, gt, gte, has, hasIn, head, * identity, includes, indexOf, inRange, invoke, isArguments, isArray, isArrayBuffer, * isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, * isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, * isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, * isSafeInteger, isSet, isString, isUndefined, isTypedArray, isWeakMap, isWeakSet, join, * kebabCase, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, max, maxBy, mean, meanBy, * min, minBy, multiply, noConflict, noop, now, nth, pad, padEnd, padStart, parseInt, pop, * random, reduce, reduceRight, repeat, result, round, runInContext, sample, shift, size, * snakeCase, some, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy, startCase, * startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, * template, times, toFinite, toInteger, toJSON, toLength, toLower, toNumber, toSafeInteger, * toString, toUpper, trim, trimEnd, trimStart, truncate, unescape, uniqueId, upperCase, * upperFirst, value, and words. **/ <T>(value: T): LoDashImplicitWrapper<T>; /** * The semantic version number. **/ VERSION: string; /** * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby * (ERB). Change the following template settings to use alternative delimiters. **/ templateSettings: TemplateSettings; } /** * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby * (ERB). Change the following template settings to use alternative delimiters. **/ interface TemplateSettings { /** * The "escape" delimiter. **/ escape?: RegExp; /** * The "evaluate" delimiter. **/ evaluate?: RegExp; /** * An object to import into the template as local variables. **/ imports?: Dictionary<any>; /** * The "interpolate" delimiter. **/ interpolate?: RegExp; /** * Used to reference the data object in the template text. **/ variable?: string; } /** * Creates a cache object to store key/value pairs. */ interface MapCache { /** * Removes `key` and its value from the cache. * @param key The key of the value to remove. * @return Returns `true` if the entry was removed successfully, else `false`. */ delete(key: any): boolean; /** * Gets the cached value for `key`. * @param key The key of the value to get. * @return Returns the cached value. */ get(key: any): any; /** * Checks if a cached value for `key` exists. * @param key The key of the entry to check. * @return Returns `true` if an entry for `key` exists, else `false`. */ has(key: any): boolean; /** * Sets `value` to `key` of the cache. * @param key The key of the value to cache. * @param value The value to cache. * @return Returns the cache object. */ set(key: any, value: any): this; /** * Removes all key-value entries from the map. */ clear?: () => void; } interface MapCacheConstructor { new (): MapCache; } interface LoDashImplicitWrapper<TValue> extends LoDashWrapper<TValue> { pop<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>): T | undefined; push<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>, ...items: T[]): this; shift<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>): T | undefined; sort<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>, compareFn?: (a: T, b: T) => number): this; splice<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>, start: number, deleteCount?: number, ...items: T[]): this; unshift<T>(this: LoDashImplicitWrapper<List<T> | null | undefined>, ...items: T[]): this; } interface LoDashExplicitWrapper<TValue> extends LoDashWrapper<TValue> { pop<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>): LoDashExplicitWrapper<T | undefined>; push<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>, ...items: T[]): this; shift<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>): LoDashExplicitWrapper<T | undefined>; sort<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>, compareFn?: (a: T, b: T) => number): this; splice<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>, start: number, deleteCount?: number, ...items: T[]): this; unshift<T>(this: LoDashExplicitWrapper<List<T> | null | undefined>, ...items: T[]): this; } type NotVoid = {} | null | undefined; type IterateeShorthand<T> = PropertyName | [PropertyName, any] | PartialDeep<T>; type ArrayIterator<T, TResult> = (value: T, index: number, collection: T[]) => TResult; type ListIterator<T, TResult> = (value: T, index: number, collection: List<T>) => TResult; type ListIteratee<T> = ListIterator<T, NotVoid> | IterateeShorthand<T>; type ListIterateeCustom<T, TResult> = ListIterator<T, TResult> | IterateeShorthand<T>; type ListIteratorTypeGuard<T, S extends T> = (value: T, index: number, collection: List<T>) => value is S; // Note: key should be string, not keyof T, because the actual object may contain extra properties that were not specified in the type. type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; type ObjectIteratee<TObject> = ObjectIterator<TObject, NotVoid> | IterateeShorthand<TObject[keyof TObject]>; type ObjectIterateeCustom<TObject, TResult> = ObjectIterator<TObject, TResult> | IterateeShorthand<TObject[keyof TObject]>; type ObjectIteratorTypeGuard<TObject, S extends TObject[keyof TObject]> = (value: TObject[keyof TObject], key: string, collection: TObject) => value is S; type StringIterator<TResult> = (char: string, index: number, string: string) => TResult; /** @deprecated Use MemoVoidArrayIterator or MemoVoidDictionaryIterator instead. */ type MemoVoidIterator<T, TResult> = (prev: TResult, curr: T, indexOrKey: any, list: T[]) => void; /** @deprecated Use MemoListIterator or MemoObjectIterator instead. */ type MemoIterator<T, TResult> = (prev: TResult, curr: T, indexOrKey: any, list: T[]) => TResult; type MemoListIterator<T, TResult, TList> = (prev: TResult, curr: T, index: number, list: TList) => TResult; type MemoObjectIterator<T, TResult, TList> = (prev: TResult, curr: T, key: string, list: TList) => TResult; type MemoIteratorCapped<T, TResult> = (prev: TResult, curr: T) => TResult; type MemoIteratorCappedRight<T, TResult> = (curr: T, prev: TResult) => TResult; type MemoVoidArrayIterator<T, TResult> = (acc: TResult, curr: T, index: number, arr: T[]) => void; type MemoVoidDictionaryIterator<T, TResult> = (acc: TResult, curr: T, key: string, dict: Dictionary<T>) => void; type MemoVoidIteratorCapped<T, TResult> = (acc: TResult, curr: T) => void; type ValueIteratee<T> = ((value: T) => NotVoid) | IterateeShorthand<T>; type ValueIterateeCustom<T, TResult> = ((value: T) => TResult) | IterateeShorthand<T>; type ValueIteratorTypeGuard<T, S extends T> = (value: T) => value is S; type ValueKeyIteratee<T> = ((value: T, key: string) => NotVoid) | IterateeShorthand<T>; type ValueKeyIterateeTypeGuard<T, S extends T> = (value: T, key: string) => value is S; type Comparator<T> = (a: T, b: T) => boolean; type Comparator2<T1, T2> = (a: T1, b: T2) => boolean; type PropertyName = string | number | symbol; type PropertyPath = Many<PropertyName>; type Omit<T, K extends keyof T> = Pick<T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never })[keyof T]>; /** Common interface between Arrays and jQuery objects */ type List<T> = ArrayLike<T>; interface Dictionary<T> { [index: string]: T; } interface NumericDictionary<T> { [index: number]: T; } // Crazy typedef needed get _.omit to work properly with Dictionary and NumericDictionary type AnyKindOfDictionary = | Dictionary<{} | null | undefined> | NumericDictionary<{} | null | undefined>; interface Cancelable { cancel(): void; flush(): void; } type PartialDeep<T> = { [P in keyof T]?: PartialDeep<T[P]>; }; // For backwards compatibility type LoDashImplicitArrayWrapper<T> = LoDashImplicitWrapper<T[]>; type LoDashImplicitNillableArrayWrapper<T> = LoDashImplicitWrapper<T[] | null | undefined>; type LoDashImplicitObjectWrapper<T> = LoDashImplicitWrapper<T>; type LoDashImplicitNillableObjectWrapper<T> = LoDashImplicitWrapper<T | null | undefined>; type LoDashImplicitNumberArrayWrapper = LoDashImplicitWrapper<number[]>; type LoDashImplicitStringWrapper = LoDashImplicitWrapper<string>; type LoDashExplicitArrayWrapper<T> = LoDashExplicitWrapper<T[]>; type LoDashExplicitNillableArrayWrapper<T> = LoDashExplicitWrapper<T[] | null | undefined>; type LoDashExplicitObjectWrapper<T> = LoDashExplicitWrapper<T>; type LoDashExplicitNillableObjectWrapper<T> = LoDashExplicitWrapper<T | null | undefined>; type LoDashExplicitNumberArrayWrapper = LoDashExplicitWrapper<number[]>; type LoDashExplicitStringWrapper = LoDashExplicitWrapper<string>; type DictionaryIterator<T, TResult> = ObjectIterator<Dictionary<T>, TResult>; type DictionaryIteratee<T> = ObjectIteratee<Dictionary<T>>; type DictionaryIteratorTypeGuard<T, S extends T> = ObjectIteratorTypeGuard<Dictionary<T>, S>; // NOTE: keys of objects at run time are always strings, even when a NumericDictionary is being iterated. type NumericDictionaryIterator<T, TResult> = (value: T, key: string, collection: NumericDictionary<T>) => TResult; type NumericDictionaryIteratee<T> = NumericDictionaryIterator<T, NotVoid> | IterateeShorthand<T>; type NumericDictionaryIterateeCustom<T, TResult> = NumericDictionaryIterator<T, TResult> | IterateeShorthand<T>; }
BigBoss424/portfolio
v8/development/node_modules/@types/lodash/common/common.d.ts
TypeScript
apache-2.0
14,825
[ 30522, 12324, 1035, 1027, 5478, 1006, 1000, 1012, 1012, 1013, 5950, 1000, 1007, 1025, 1013, 1013, 24529, 4115, 2102, 1024, 4487, 19150, 1011, 2279, 1011, 2240, 1024, 9384, 1011, 9167, 1011, 13520, 1011, 16913, 28295, 2828, 3795, 19362, 2092...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Agaricus commistus Pers. SPECIES #### Status ACCEPTED #### According to Index Fungorum #### Published in null #### Original name Agaricus commistus Pers. ### Remarks null
mdoering/backbone
life/Fungi/Basidiomycota/Agaricomycetes/Agaricales/Agaricaceae/Agaricus/Agaricus commistus/README.md
Markdown
apache-2.0
177
[ 30522, 1001, 12943, 8486, 7874, 4012, 23738, 2271, 2566, 2015, 1012, 2427, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 5950, 4569, 20255, 2819, 1001, 1001, 1001, 1001, 2405, 1999, 19701, 1001, 1001, 1001, 1001, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"57071060","logradouro":"Rua Eduardo Jorge Lopes Novaes","bairro":"Clima Bom","cidade":"Macei\u00f3","uf":"AL","estado":"Alagoas"});
lfreneda/cepdb
api/v1/57071060.jsonp.js
JavaScript
cc0-1.0
146
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 24902, 2581, 10790, 16086, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 21766, 2050, 14846, 10853, 8840, 10374, 6846, 2229, 1000, 1010, 1000, 21790, 18...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright LWJGL. All rights reserved. * License terms: https://www.lwjgl.org/license * MACHINE GENERATED FILE, DO NOT EDIT */ package org.lwjgl.openxr; import javax.annotation.*; import java.nio.*; import org.lwjgl.*; import org.lwjgl.system.*; import static org.lwjgl.system.Checks.*; import static org.lwjgl.system.MemoryUtil.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.openxr.MSFTSpatialAnchorPersistence.*; /** * The name to identify a Spatial anchor persistence operations. * * <h5>Description</h5> * * <p>If an {@link XrSpatialAnchorPersistenceNameMSFT} with an empty {@code name} value is passed to any function as a parameter, that function <b>must</b> return {@link MSFTSpatialAnchorPersistence#XR_ERROR_SPATIAL_ANCHOR_NAME_INVALID_MSFT ERROR_SPATIAL_ANCHOR_NAME_INVALID_MSFT}.</p> * * <h5>Valid Usage (Implicit)</h5> * * <ul> * <li>The {@link MSFTSpatialAnchorPersistence XR_MSFT_spatial_anchor_persistence} extension <b>must</b> be enabled prior to using {@link XrSpatialAnchorPersistenceNameMSFT}</li> * <li>{@code name} <b>must</b> be a null-terminated UTF-8 string whose length is less than or equal to {@link MSFTSpatialAnchorPersistence#XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT}</li> * </ul> * * <h5>See Also</h5> * * <p>{@link XrSpatialAnchorFromPersistedAnchorCreateInfoMSFT}, {@link XrSpatialAnchorPersistenceInfoMSFT}, {@link MSFTSpatialAnchorPersistence#xrClearSpatialAnchorStoreMSFT ClearSpatialAnchorStoreMSFT}, {@link MSFTSpatialAnchorPersistence#xrEnumeratePersistedSpatialAnchorNamesMSFT EnumeratePersistedSpatialAnchorNamesMSFT}, {@link MSFTSpatialAnchorPersistence#xrUnpersistSpatialAnchorMSFT UnpersistSpatialAnchorMSFT}</p> * * <h3>Layout</h3> * * <pre><code> * struct XrSpatialAnchorPersistenceNameMSFT { * char {@link #name}[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]; * }</code></pre> */ public class XrSpatialAnchorPersistenceNameMSFT extends Struct implements NativeResource { /** The struct size in bytes. */ public static final int SIZEOF; /** The struct alignment in bytes. */ public static final int ALIGNOF; /** The struct member offsets. */ public static final int NAME; static { Layout layout = __struct( __array(1, XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT) ); SIZEOF = layout.getSize(); ALIGNOF = layout.getAlignment(); NAME = layout.offsetof(0); } /** * Creates a {@code XrSpatialAnchorPersistenceNameMSFT} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be * visible to the struct instance and vice versa. * * <p>The created instance holds a strong reference to the container object.</p> */ public XrSpatialAnchorPersistenceNameMSFT(ByteBuffer container) { super(memAddress(container), __checkContainer(container, SIZEOF)); } @Override public int sizeof() { return SIZEOF; } /** a null terminated character array of size {@link MSFTSpatialAnchorPersistence#XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT}. */ @NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") public ByteBuffer name() { return nname(address()); } /** a null terminated character array of size {@link MSFTSpatialAnchorPersistence#XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT}. */ @NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") public String nameString() { return nnameString(address()); } /** Copies the specified encoded string to the {@link #name} field. */ public XrSpatialAnchorPersistenceNameMSFT name(@NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") ByteBuffer value) { nname(address(), value); return this; } /** * Copies the specified struct data to this struct. * * @param src the source struct * * @return this struct */ public XrSpatialAnchorPersistenceNameMSFT set(XrSpatialAnchorPersistenceNameMSFT src) { memCopy(src.address(), address(), SIZEOF); return this; } // ----------------------------------- /** Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */ public static XrSpatialAnchorPersistenceNameMSFT malloc() { return wrap(XrSpatialAnchorPersistenceNameMSFT.class, nmemAllocChecked(SIZEOF)); } /** Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */ public static XrSpatialAnchorPersistenceNameMSFT calloc() { return wrap(XrSpatialAnchorPersistenceNameMSFT.class, nmemCallocChecked(1, SIZEOF)); } /** Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance allocated with {@link BufferUtils}. */ public static XrSpatialAnchorPersistenceNameMSFT create() { ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF); return wrap(XrSpatialAnchorPersistenceNameMSFT.class, memAddress(container), container); } /** Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance for the specified memory address. */ public static XrSpatialAnchorPersistenceNameMSFT create(long address) { return wrap(XrSpatialAnchorPersistenceNameMSFT.class, address); } /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static XrSpatialAnchorPersistenceNameMSFT createSafe(long address) { return address == NULL ? null : wrap(XrSpatialAnchorPersistenceNameMSFT.class, address); } /** * Returns a new {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. * * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer malloc(int capacity) { return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity); } /** * Returns a new {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. * * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer calloc(int capacity) { return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity); } /** * Returns a new {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance allocated with {@link BufferUtils}. * * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer create(int capacity) { ByteBuffer container = __create(capacity, SIZEOF); return wrap(Buffer.class, memAddress(container), capacity, container); } /** * Create a {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance at the specified memory. * * @param address the memory address * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer create(long address, int capacity) { return wrap(Buffer.class, address, capacity); } /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ @Nullable public static XrSpatialAnchorPersistenceNameMSFT.Buffer createSafe(long address, int capacity) { return address == NULL ? null : wrap(Buffer.class, address, capacity); } /** * Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance allocated on the specified {@link MemoryStack}. * * @param stack the stack from which to allocate */ public static XrSpatialAnchorPersistenceNameMSFT malloc(MemoryStack stack) { return wrap(XrSpatialAnchorPersistenceNameMSFT.class, stack.nmalloc(ALIGNOF, SIZEOF)); } /** * Returns a new {@code XrSpatialAnchorPersistenceNameMSFT} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. * * @param stack the stack from which to allocate */ public static XrSpatialAnchorPersistenceNameMSFT calloc(MemoryStack stack) { return wrap(XrSpatialAnchorPersistenceNameMSFT.class, stack.ncalloc(ALIGNOF, 1, SIZEOF)); } /** * Returns a new {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance allocated on the specified {@link MemoryStack}. * * @param stack the stack from which to allocate * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer malloc(int capacity, MemoryStack stack) { return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity); } /** * Returns a new {@link XrSpatialAnchorPersistenceNameMSFT.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero. * * @param stack the stack from which to allocate * @param capacity the buffer capacity */ public static XrSpatialAnchorPersistenceNameMSFT.Buffer calloc(int capacity, MemoryStack stack) { return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity); } // ----------------------------------- /** Unsafe version of {@link #name}. */ public static ByteBuffer nname(long struct) { return memByteBuffer(struct + XrSpatialAnchorPersistenceNameMSFT.NAME, XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT); } /** Unsafe version of {@link #nameString}. */ public static String nnameString(long struct) { return memUTF8(struct + XrSpatialAnchorPersistenceNameMSFT.NAME); } /** Unsafe version of {@link #name(ByteBuffer) name}. */ public static void nname(long struct, ByteBuffer value) { if (CHECKS) { checkNT1(value); checkGT(value, XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT); } memCopy(memAddress(value), struct + XrSpatialAnchorPersistenceNameMSFT.NAME, value.remaining()); } // ----------------------------------- /** An array of {@link XrSpatialAnchorPersistenceNameMSFT} structs. */ public static class Buffer extends StructBuffer<XrSpatialAnchorPersistenceNameMSFT, Buffer> implements NativeResource { private static final XrSpatialAnchorPersistenceNameMSFT ELEMENT_FACTORY = XrSpatialAnchorPersistenceNameMSFT.create(-1L); /** * Creates a new {@code XrSpatialAnchorPersistenceNameMSFT.Buffer} instance backed by the specified container. * * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided * by {@link XrSpatialAnchorPersistenceNameMSFT#SIZEOF}, and its mark will be undefined. * * <p>The created buffer instance holds a strong reference to the container object.</p> */ public Buffer(ByteBuffer container) { super(container, container.remaining() / SIZEOF); } public Buffer(long address, int cap) { super(address, null, -1, 0, cap, cap); } Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { super(address, container, mark, pos, lim, cap); } @Override protected Buffer self() { return this; } @Override protected XrSpatialAnchorPersistenceNameMSFT getElementFactory() { return ELEMENT_FACTORY; } /** @return a {@link ByteBuffer} view of the {@link XrSpatialAnchorPersistenceNameMSFT#name} field. */ @NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") public ByteBuffer name() { return XrSpatialAnchorPersistenceNameMSFT.nname(address()); } /** @return the null-terminated string stored in the {@link XrSpatialAnchorPersistenceNameMSFT#name} field. */ @NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") public String nameString() { return XrSpatialAnchorPersistenceNameMSFT.nnameString(address()); } /** Copies the specified encoded string to the {@link XrSpatialAnchorPersistenceNameMSFT#name} field. */ public XrSpatialAnchorPersistenceNameMSFT.Buffer name(@NativeType("char[XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT]") ByteBuffer value) { XrSpatialAnchorPersistenceNameMSFT.nname(address(), value); return this; } } }
LWJGL-CI/lwjgl3
modules/lwjgl/openxr/src/generated/java/org/lwjgl/openxr/XrSpatialAnchorPersistenceNameMSFT.java
Java
bsd-3-clause
12,829
[ 30522, 1013, 1008, 1008, 9385, 1048, 2860, 3501, 23296, 1012, 2035, 2916, 9235, 1012, 1008, 6105, 3408, 1024, 16770, 1024, 1013, 1013, 7479, 1012, 1048, 2860, 3501, 23296, 1012, 8917, 1013, 6105, 1008, 3698, 7013, 5371, 1010, 2079, 2025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * * Apply your custom CSS here * */ body { } a { } .page-body.skin-white .sidebar-menu .main-menu li.has-sub>a:before { color: #666; } /*navbar*/ .navbar.horizontal-menu.navbar-minimal.navbar-fixed-top+.page-container>div>.sidebar-menu.fixed .sidebar-menu-inner{ top: 55px; } /*validate forms*/ form .form-group.validate-has-error .form-control + div { display: block; padding-top: 5px; font-size: 12px; color: #cc3f44; } form .form-group.validate-has-error .input-group + div { display: block; padding-top: 5px; font-size: 12px; color: #cc3f44; } form .form-group.validate-has-error .ui-select-container + div { display: block; padding-top: 5px; font-size: 12px; color: #cc3f44; } .ui-select-bootstrap button{ color: #333; background-color: #fff; border-color: #ccc; }
carlosthe19916/SistCoopEE_App
app/styles/custom.css
CSS
gpl-2.0
851
[ 30522, 1013, 1008, 1008, 1008, 1008, 6611, 2115, 7661, 20116, 2015, 2182, 1008, 1008, 1013, 2303, 1063, 1065, 1037, 1063, 1065, 1012, 3931, 1011, 2303, 1012, 3096, 1011, 2317, 1012, 2217, 8237, 1011, 12183, 1012, 2364, 1011, 12183, 5622, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.analogweb.servlet; import java.lang.annotation.Annotation; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.http.HttpSession; import org.analogweb.InvocationMetadata; import org.analogweb.RequestContext; import org.analogweb.RequestValueResolver; import org.analogweb.util.RequestContextResolverUtils; /** * @author y2k2mt */ public class ServletComponentsValueResolver implements RequestValueResolver { @Override public Object resolveValue(RequestContext request, InvocationMetadata metadata, String query, Class<?> requiredType, Annotation[] parameterAnnotations) { ServletRequestContext src = RequestContextResolverUtils .resolveRequestContext(request); if (src == null) { return null; } if (ServletRequest.class.isAssignableFrom(requiredType)) { return src.getServletRequest(); } else if (HttpSession.class.isAssignableFrom(requiredType)) { return src.getServletRequest().getSession(true); } else if (ServletContext.class.isAssignableFrom(requiredType)) { return src.getServletContext(); } return null; } }
analogweb/servlet-plugin
src/main/java/org/analogweb/servlet/ServletComponentsValueResolver.java
Java
mit
1,117
[ 30522, 7427, 8917, 1012, 11698, 8545, 2497, 1012, 14262, 2615, 7485, 1025, 12324, 9262, 1012, 11374, 1012, 5754, 17287, 3508, 1012, 5754, 17287, 3508, 1025, 12324, 9262, 2595, 1012, 14262, 2615, 7485, 1012, 14262, 2615, 7485, 8663, 18209, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
{-# LANGUAGE DeriveDataTypeable #-} module WFF where import qualified Data.Map as M import Test.QuickCheck hiding ((.||.), (==>), (.&&.)) import qualified Data.Set as S import Data.Data import Data.Generics.Uniplate.Data import Data.List hiding (lookup, union) import Prelude hiding (lookup) import Control.Applicative hiding (empty) data WFF = Var String | And WFF WFF | Or WFF WFF | Not WFF | Impl WFF WFF | Eqv WFF WFF deriving (Data) instance Show WFF where show (Var s) = s show (And x y) = "("++(show x) ++ " && "++(show y)++")" show (Or x y) ="("++(show x) ++ " || "++(show y)++")" show (Not x) = "~"++(show x) show (Impl x y) = "("++(show x) ++ "=>" ++ (show y)++")" show (Eqv x y) = "("++(show x) ++ "=" ++ (show y) ++ ")" instance Arbitrary WFF where arbitrary = sized myArbitrary where myArbitrary 0 = do s <- oneof (map (return . show) [1..30]) return (Var s) myArbitrary n = oneof [ binary n And, binary n Or, binary n Impl, binary n Eqv, fmap Not (myArbitrary (n-1)), var ] where var = do s <- oneof (map (return . show) [1..30]) return (Var s) binary n f = do s <- myArbitrary (div n 2) t <- myArbitrary (div n 2) return (f s t) t `xor` t' = (t .|| t') .&& (n (t .&& t')) t .&& t' = And t t' t .|| t' = Or t t' t ==> t' = Impl t t' t <=> t' = Eqv t t' n t = Not t v s = Var s variables wff = [v | Var v <- universe wff] fromJust (Just x) = x fromJust _ = undefined eval :: M.Map String Bool -> WFF -> Bool eval m (Var s) = fromJust $ M.lookup s m eval m (And x y) = (&&) (eval m x) (eval m y) eval m (Or x y) = (||) (eval m x) (eval m y) eval m (Not y) = not (eval m y) eval m (Impl x y) = (not (eval m x)) || (eval m y) eval m (Eqv x y) = (==) (eval m x) (eval m y)
patrikja/GRACeFUL
ConstraintModelling/WFF.hs
Haskell
bsd-3-clause
2,457
[ 30522, 1063, 1011, 1001, 2653, 5173, 6790, 13874, 3085, 1001, 1011, 1065, 11336, 1059, 4246, 2073, 12324, 4591, 2951, 1012, 4949, 2004, 1049, 12324, 3231, 1012, 4248, 5403, 3600, 6318, 1006, 1006, 1012, 1064, 1064, 1012, 1007, 1010, 1006, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_27) on Sat Oct 06 02:58:48 EDT 2012 --> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <TITLE> org.apache.lucene.codecs.lucene40 (Lucene 4.0.0 API) </TITLE> <META NAME="date" CONTENT="2012-10-06"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="org.apache.lucene.codecs.lucene40 (Lucene 4.0.0 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../../org/apache/lucene/codecs/lucene3x/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp; &nbsp;<A HREF="../../../../../org/apache/lucene/codecs/lucene40/values/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/lucene/codecs/lucene40/package-summary.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <H2> Package org.apache.lucene.codecs.lucene40 </H2> Lucene 4.0 file format. <P> <B>See:</B> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="#package_description"><B>Description</B></A> <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Class Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40Codec.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40Codec</A></B></TD> <TD>Implements the Lucene 4.0 index format, with configurable per-field postings formats.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40DocValuesConsumer.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40DocValuesConsumer</A></B></TD> <TD>Lucene 4.0 PerDocConsumer implementation that uses compound file.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40DocValuesFormat</A></B></TD> <TD>Lucene 4.0 DocValues format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40DocValuesProducer.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40DocValuesProducer</A></B></TD> <TD>Lucene 4.0 PerDocProducer implementation that uses compound file.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40FieldInfosFormat</A></B></TD> <TD>Lucene 4.0 Field Infos format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40FieldInfosReader</A></B></TD> <TD>Lucene 4.0 FieldInfos reader.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40FieldInfosWriter</A></B></TD> <TD>Lucene 4.0 FieldInfos writer.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40LiveDocsFormat</A></B></TD> <TD>Lucene 4.0 Live Documents Format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40NormsFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40NormsFormat</A></B></TD> <TD>Lucene 4.0 Norms Format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40NormsFormat.Lucene40NormsDocValuesConsumer.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40NormsFormat.Lucene40NormsDocValuesConsumer</A></B></TD> <TD>Lucene 4.0 PerDocConsumer implementation that uses compound file.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40NormsFormat.Lucene40NormsDocValuesProducer.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40NormsFormat.Lucene40NormsDocValuesProducer</A></B></TD> <TD>Lucene 4.0 PerDocProducer implementation that uses compound file.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsBaseFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40PostingsBaseFormat</A></B></TD> <TD>Provides a <A HREF="../../../../../org/apache/lucene/codecs/PostingsReaderBase.html" title="class in org.apache.lucene.codecs"><CODE>PostingsReaderBase</CODE></A> and <A HREF="../../../../../org/apache/lucene/codecs/PostingsWriterBase.html" title="class in org.apache.lucene.codecs"><CODE>PostingsWriterBase</CODE></A>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40PostingsFormat</A></B></TD> <TD>Lucene 4.0 Postings format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40PostingsReader</A></B></TD> <TD>Concrete class that reads the 4.0 frq/prox postings format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40PostingsWriter</A></B></TD> <TD>Concrete class that writes the 4.0 frq/prx postings format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40SegmentInfoFormat</A></B></TD> <TD>Lucene 4.0 Segment info format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40SegmentInfoReader</A></B></TD> <TD>Lucene 4.0 implementation of <A HREF="../../../../../org/apache/lucene/codecs/SegmentInfoReader.html" title="class in org.apache.lucene.codecs"><CODE>SegmentInfoReader</CODE></A>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40SegmentInfoWriter</A></B></TD> <TD>Lucene 4.0 implementation of <A HREF="../../../../../org/apache/lucene/codecs/SegmentInfoWriter.html" title="class in org.apache.lucene.codecs"><CODE>SegmentInfoWriter</CODE></A>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SkipListReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40SkipListReader</A></B></TD> <TD>Implements the skip list reader for the 4.0 posting list format that stores positions and payloads.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SkipListWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40SkipListWriter</A></B></TD> <TD>Implements the skip list writer for the 4.0 posting list format that stores positions and payloads.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40StoredFieldsFormat</A></B></TD> <TD>Lucene 4.0 Stored Fields Format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40StoredFieldsReader</A></B></TD> <TD>Class responsible for access to stored document fields.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40StoredFieldsWriter</A></B></TD> <TD>Class responsible for writing stored document fields.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40TermVectorsFormat</A></B></TD> <TD>Lucene 4.0 Term Vectors format.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsReader.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40TermVectorsReader</A></B></TD> <TD>Lucene 4.0 Term Vectors reader.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.html" title="class in org.apache.lucene.codecs.lucene40">Lucene40TermVectorsWriter</A></B></TD> <TD>Lucene 4.0 Term Vectors writer.</TD> </TR> </TABLE> &nbsp; <P> <A NAME="package_description"><!-- --></A><H2> Package org.apache.lucene.codecs.lucene40 Description </H2> <P> Lucene 4.0 file format. <h1>Apache Lucene - Index File Formats</h1> <div> <ul> <li><a href="#Introduction">Introduction</a></li> <li><a href="#Definitions">Definitions</a> <ul> <li><a href="#Inverted_Indexing">Inverted Indexing</a></li> <li><a href="#Types_of_Fields">Types of Fields</a></li> <li><a href="#Segments">Segments</a></li> <li><a href="#Document_Numbers">Document Numbers</a></li> </ul> </li> <li><a href="#Overview">Index Structure Overview</a></li> <li><a href="#File_Naming">File Naming</a></li> <li><a href="#file-names">Summary of File Extensions</a></li> <ul> <li><a href="#Lock_File">Lock File</a></li> <li><a href="#History">History</a></li> <li><a href="#Limitations">Limitations</a></li> </ul> </div> <a name="Introduction"></a> <h2>Introduction</h2> <div> <p>This document defines the index file formats used in this version of Lucene. If you are using a different version of Lucene, please consult the copy of <code>docs/</code> that was distributed with the version you are using.</p> <p>Apache Lucene is written in Java, but several efforts are underway to write <a href="http://wiki.apache.org/lucene-java/LuceneImplementations">versions of Lucene in other programming languages</a>. If these versions are to remain compatible with Apache Lucene, then a language-independent definition of the Lucene index format is required. This document thus attempts to provide a complete and independent definition of the Apache Lucene file formats.</p> <p>As Lucene evolves, this document should evolve. Versions of Lucene in different programming languages should endeavor to agree on file formats, and generate new versions of this document.</p> </div> <a name="Definitions" id="Definitions"></a> <h2>Definitions</h2> <div> <p>The fundamental concepts in Lucene are index, document, field and term.</p> <p>An index contains a sequence of documents.</p> <ul> <li>A document is a sequence of fields.</li> <li>A field is a named sequence of terms.</li> <li>A term is a sequence of bytes.</li> </ul> <p>The same sequence of bytes in two different fields is considered a different term. Thus terms are represented as a pair: the string naming the field, and the bytes within the field.</p> <a name="Inverted_Indexing"></a> <h3>Inverted Indexing</h3> <p>The index stores statistics about terms in order to make term-based search more efficient. Lucene's index falls into the family of indexes known as an <i>inverted index.</i> This is because it can list, for a term, the documents that contain it. This is the inverse of the natural relationship, in which documents list terms.</p> <a name="Types_of_Fields"></a> <h3>Types of Fields</h3> <p>In Lucene, fields may be <i>stored</i>, in which case their text is stored in the index literally, in a non-inverted manner. Fields that are inverted are called <i>indexed</i>. A field may be both stored and indexed.</p> <p>The text of a field may be <i>tokenized</i> into terms to be indexed, or the text of a field may be used literally as a term to be indexed. Most fields are tokenized, but sometimes it is useful for certain identifier fields to be indexed literally.</p> <p>See the <A HREF="../../../../../org/apache/lucene/document/Field.html" title="class in org.apache.lucene.document"><CODE>Field</CODE></A> java docs for more information on Fields.</p> <a name="Segments" id="Segments"></a> <h3>Segments</h3> <p>Lucene indexes may be composed of multiple sub-indexes, or <i>segments</i>. Each segment is a fully independent index, which could be searched separately. Indexes evolve by:</p> <ol> <li>Creating new segments for newly added documents.</li> <li>Merging existing segments.</li> </ol> <p>Searches may involve multiple segments and/or multiple indexes, each index potentially composed of a set of segments.</p> <a name="Document_Numbers"></a> <h3>Document Numbers</h3> <p>Internally, Lucene refers to documents by an integer <i>document number</i>. The first document added to an index is numbered zero, and each subsequent document added gets a number one greater than the previous.</p> <p>Note that a document's number may change, so caution should be taken when storing these numbers outside of Lucene. In particular, numbers may change in the following situations:</p> <ul> <li> <p>The numbers stored in each segment are unique only within the segment, and must be converted before they can be used in a larger context. The standard technique is to allocate each segment a range of values, based on the range of numbers used in that segment. To convert a document number from a segment to an external value, the segment's <i>base</i> document number is added. To convert an external value back to a segment-specific value, the segment is identified by the range that the external value is in, and the segment's base value is subtracted. For example two five document segments might be combined, so that the first segment has a base value of zero, and the second of five. Document three from the second segment would have an external value of eight.</p> </li> <li> <p>When documents are deleted, gaps are created in the numbering. These are eventually removed as the index evolves through merging. Deleted documents are dropped when segments are merged. A freshly-merged segment thus has no gaps in its numbering.</p> </li> </ul> </div> <a name="Overview" id="Overview"></a> <h2>Index Structure Overview</h2> <div> <p>Each segment index maintains the following:</p> <ul> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Segment info</CODE></A>. This contains metadata about a segment, such as the number of documents, what files it uses, </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Field names</CODE></A>. This contains the set of field names used in the index. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Stored Field values</CODE></A>. This contains, for each document, a list of attribute-value pairs, where the attributes are field names. These are used to store auxiliary information about the document, such as its title, url, or an identifier to access a database. The set of stored fields are what is returned for each hit when searching. This is keyed by document number. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term dictionary</CODE></A>. A dictionary containing all of the terms used in all of the indexed fields of all of the documents. The dictionary also contains the number of documents which contain the term, and pointers to the term's frequency and proximity data. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Frequency data</CODE></A>. For each term in the dictionary, the numbers of all the documents that contain that term, and the frequency of the term in that document, unless frequencies are omitted (IndexOptions.DOCS_ONLY) </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Proximity data</CODE></A>. For each term in the dictionary, the positions that the term occurs in each document. Note that this will not exist if all fields in all documents omit position data. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40NormsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Normalization factors</CODE></A>. For each field in each document, a value is stored that is multiplied into the score for hits on that field. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Vectors</CODE></A>. For each field in each document, the term vector (sometimes called document vector) may be stored. A term vector consists of term text and term frequency. To add Term Vectors to your index see the <A HREF="../../../../../org/apache/lucene/document/Field.html" title="class in org.apache.lucene.document"><CODE>Field</CODE></A> constructors </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Per-document values</CODE></A>. Like stored values, these are also keyed by document number, but are generally intended to be loaded into main memory for fast access. Whereas stored values are generally intended for summary results from searches, per-document values are useful for things like scoring factors. </li> <li> <A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Deleted documents</CODE></A>. An optional file indicating which documents are deleted. </li> </ul> <p>Details on each of these are provided in their linked pages.</p> </div> <a name="File_Naming"></a> <h2>File Naming</h2> <div> <p>All files belonging to a segment have the same name with varying extensions. The extensions correspond to the different file formats described below. When using the Compound File format (default in 1.4 and greater) these files (except for the Segment info file, the Lock file, and Deleted documents file) are collapsed into a single .cfs file (see below for details)</p> <p>Typically, all segments in an index are stored in a single directory, although this is not required.</p> <p>As of version 2.1 (lock-less commits), file names are never re-used (there is one exception, "segments.gen", see below). That is, when any file is saved to the Directory it is given a never before used filename. This is achieved using a simple generations approach. For example, the first segments file is segments_1, then segments_2, etc. The generation is a sequential long integer represented in alpha-numeric (base 36) form.</p> </div> <a name="file-names" id="file-names"></a> <h2>Summary of File Extensions</h2> <div> <p>The following table summarizes the names and extensions of the files in Lucene:</p> <table cellspacing="1" cellpadding="4"> <tr> <th>Name</th> <th>Extension</th> <th>Brief Description</th> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/index/SegmentInfos.html" title="class in org.apache.lucene.index"><CODE>Segments File</CODE></A></td> <td>segments.gen, segments_N</td> <td>Stores information about a commit point</td> </tr> <tr> <td><a href="#Lock_File">Lock File</a></td> <td>write.lock</td> <td>The Write lock prevents multiple IndexWriters from writing to the same file.</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40SegmentInfoFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Segment Info</CODE></A></td> <td>.si</td> <td>Stores metadata about a segment</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/store/CompoundFileDirectory.html" title="class in org.apache.lucene.store"><CODE>Compound File</CODE></A></td> <td>.cfs, .cfe</td> <td>An optional "virtual" file consisting of all the other index files for systems that frequently run out of file handles.</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Fields</CODE></A></td> <td>.fnm</td> <td>Stores information about the fields</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Field Index</CODE></A></td> <td>.fdx</td> <td>Contains pointers to field data</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Field Data</CODE></A></td> <td>.fdt</td> <td>The stored fields for documents</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Dictionary</CODE></A></td> <td>.tim</td> <td>The term dictionary, stores term info</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Index</CODE></A></td> <td>.tip</td> <td>The index into the Term Dictionary</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Frequencies</CODE></A></td> <td>.frq</td> <td>Contains the list of docs which contain each term along with frequency</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Positions</CODE></A></td> <td>.prx</td> <td>Stores position information about where a term occurs in the index</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40NormsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Norms</CODE></A></td> <td>.nrm.cfs, .nrm.cfe</td> <td>Encodes length and boost factors for docs and fields</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40DocValuesFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Per-Document Values</CODE></A></td> <td>.dv.cfs, .dv.cfe</td> <td>Encodes additional scoring factors or other per-document information.</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Vector Index</CODE></A></td> <td>.tvx</td> <td>Stores offset into the document data file</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Vector Documents</CODE></A></td> <td>.tvd</td> <td>Contains information about each document that has term vectors</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40TermVectorsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Term Vector Fields</CODE></A></td> <td>.tvf</td> <td>The field level info about term vectors</td> </tr> <tr> <td><A HREF="../../../../../org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.html" title="class in org.apache.lucene.codecs.lucene40"><CODE>Deleted Documents</CODE></A></td> <td>.del</td> <td>Info about what files are deleted</td> </tr> </table> </div> <a name="Lock_File" id="Lock_File"></a> <h2>Lock File</h2> The write lock, which is stored in the index directory by default, is named "write.lock". If the lock directory is different from the index directory then the write lock will be named "XXXX-write.lock" where XXXX is a unique prefix derived from the full path to the index directory. When this file is present, a writer is currently modifying the index (adding or removing documents). This lock file ensures that only one writer is modifying the index at a time.</p> <a name="History"></a> <h2>History</h2> <p>Compatibility notes are provided in this document, describing how file formats have changed from prior versions:</p> <ul> <li>In version 2.1, the file format was changed to allow lock-less commits (ie, no more commit lock). The change is fully backwards compatible: you can open a pre-2.1 index for searching or adding/deleting of docs. When the new segments file is saved (committed), it will be written in the new file format (meaning no specific "upgrade" process is needed). But note that once a commit has occurred, pre-2.1 Lucene will not be able to read the index.</li> <li>In version 2.3, the file format was changed to allow segments to share a single set of doc store (vectors &amp; stored fields) files. This allows for faster indexing in certain cases. The change is fully backwards compatible (in the same way as the lock-less commits change in 2.1).</li> <li>In version 2.4, Strings are now written as true UTF-8 byte sequence, not Java's modified UTF-8. See <a href="http://issues.apache.org/jira/browse/LUCENE-510"> LUCENE-510</a> for details.</li> <li>In version 2.9, an optional opaque Map&lt;String,String&gt; CommitUserData may be passed to IndexWriter's commit methods (and later retrieved), which is recorded in the segments_N file. See <a href="http://issues.apache.org/jira/browse/LUCENE-1382"> LUCENE-1382</a> for details. Also, diagnostics were added to each segment written recording details about why it was written (due to flush, merge; which OS/JRE was used; etc.). See issue <a href="http://issues.apache.org/jira/browse/LUCENE-1654">LUCENE-1654</a> for details.</li> <li>In version 3.0, compressed fields are no longer written to the index (they can still be read, but on merge the new segment will write them, uncompressed). See issue <a href="http://issues.apache.org/jira/browse/LUCENE-1960">LUCENE-1960</a> for details.</li> <li>In version 3.1, segments records the code version that created them. See <a href="http://issues.apache.org/jira/browse/LUCENE-2720">LUCENE-2720</a> for details. Additionally segments track explicitly whether or not they have term vectors. See <a href="http://issues.apache.org/jira/browse/LUCENE-2811">LUCENE-2811</a> for details.</li> <li>In version 3.2, numeric fields are written as natively to stored fields file, previously they were stored in text format only.</li> <li>In version 3.4, fields can omit position data while still indexing term frequencies.</li> <li>In version 4.0, the format of the inverted index became extensible via the <A HREF="../../../../../org/apache/lucene/codecs/Codec.html" title="class in org.apache.lucene.codecs"><CODE>Codec</CODE></A> api. Fast per-document storage (<A HREF="../../../../../org/apache/lucene/index/DocValues.html" title="class in org.apache.lucene.index"><CODE>DocValues</CODE></A>) was introduced. Normalization factors need no longer be a single byte, they can be any DocValues <A HREF="../../../../../org/apache/lucene/index/DocValues.Type.html" title="enum in org.apache.lucene.index"><CODE>type</CODE></A>. Terms need not be unicode strings, they can be any byte sequence. Term offsets can optionally be indexed into the postings lists. Payloads can be stored in the term vectors.</li> </ul> <a name="Limitations" id="Limitations"></a> <h2>Limitations</h2> <div> <p>When referring to term numbers, Lucene's current implementation uses a Java <code>int</code> to hold the term index, which means the maximum number of unique terms in any single index segment is ~2.1 billion times the term index interval (default 128) = ~274 billion. This is technically not a limitation of the index file format, just of Lucene's current implementation.</p> <p>Similarly, Lucene uses a Java <code>int</code> to refer to document numbers, and the index file format uses an <code>Int32</code> on-disk to store document numbers. This is a limitation of both the index file format and the current implementation. Eventually these should be replaced with either <code>UInt64</code> values, or better yet, <A HREF="../../../../../org/apache/lucene/store/DataOutput.html#writeVInt(int)"><CODE>VInt</CODE></A> values which have no limit.</p> </div> <P> <P> <DL> </DL> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../../../org/apache/lucene/codecs/lucene3x/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp; &nbsp;<A HREF="../../../../../org/apache/lucene/codecs/lucene40/values/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/lucene/codecs/lucene40/package-summary.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> <address>Copyright &copy; 2000-2012 Apache Software Foundation. All Rights Reserved.</address> <script src='../../../../../prettify.js' type='text/javascript'></script> <script type='text/javascript'> (function(){ var oldonload = window.onload; if (typeof oldonload != 'function') { window.onload = prettyPrint; } else { window.onload = function() { oldonload(); prettyPrint(); } } })(); </script> </BODY> </HTML>
dburgmann/fbRecommender
lib/lucene-4.0.0/docs/core/org/apache/lucene/codecs/lucene40/package-summary.html
HTML
gpl-3.0
35,067
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or http://ckeditor.com/license */ CKEDITOR.plugins.setLang( 'flash', 'fo', { access: 'Script atgongd', accessAlways: 'Altíð', accessNever: 'Ongantíð', accessSameDomain: 'Sama navnaøki', alignAbsBottom: 'Abs botnur', alignAbsMiddle: 'Abs miðja', alignBaseline: 'Basislinja', alignTextTop: 'Tekst toppur', bgcolor: 'Bakgrundslitur', chkFull: 'Loyv fullan skerm', chkLoop: 'Endurspæl', chkMenu: 'Ger Flash skrá virkna', chkPlay: 'Avspælingin byrjar sjálv', flashvars: 'Variablar fyri Flash', hSpace: 'Høgri breddi', properties: 'Flash eginleikar', propertiesTab: 'Eginleikar', quality: 'Góðska', qualityAutoHigh: 'Auto høg', qualityAutoLow: 'Auto Lág', qualityBest: 'Besta', qualityHigh: 'Høg', qualityLow: 'Lág', qualityMedium: 'Meðal', scale: 'Skalering', scaleAll: 'Vís alt', scaleFit: 'Neyv skalering', scaleNoBorder: 'Eingin bordi', title: 'Flash eginleikar', vSpace: 'Vinstri breddi', validateHSpace: 'HSpace má vera eitt tal.', validateSrc: 'Vinarliga skriva tilknýti (URL)', validateVSpace: 'VSpace má vera eitt tal.', windowMode: 'Slag av rúti', windowModeOpaque: 'Ikki transparent', windowModeTransparent: 'Transparent', windowModeWindow: 'Rútur' });
chiave/gamp
public_html/ckeditor/plugins/flash/lang/fo.js
JavaScript
mit
1,374
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2494, 1011, 2286, 1010, 23616, 6499, 3126, 3401, 1011, 15296, 2080, 14161, 7875, 10609, 1012, 2035, 2916, 9235, 1012, 2005, 13202, 1010, 2156, 6105, 1012, 9108, 2030, 8299, 1024, 1013, 1013, 23616,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util.treeView; import com.intellij.ide.IdeBundle; import com.intellij.ide.UiActivity; import com.intellij.ide.UiActivityMonitor; import com.intellij.ide.util.treeView.TreeRunnable.TreeConsumer; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.*; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.ui.LoadingNode; import com.intellij.ui.treeStructure.AlwaysExpandedTree; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.*; import com.intellij.util.concurrency.LockToken; import com.intellij.util.concurrency.QueueProcessor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.*; import org.jetbrains.concurrency.AsyncPromise; import org.jetbrains.concurrency.Promise; import org.jetbrains.concurrency.Promises; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.util.List; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; /** * @deprecated use {@link com.intellij.ui.tree.AsyncTreeModel} and {@link com.intellij.ui.tree.StructureTreeModel} instead. */ @ApiStatus.ScheduledForRemoval(inVersion = "2020.3") @Deprecated public class AbstractTreeUi { private static final Logger LOG = Logger.getInstance(AbstractTreeBuilder.class); protected JTree myTree;// protected for TestNG private DefaultTreeModel myTreeModel; private AbstractTreeStructure myTreeStructure; private AbstractTreeUpdater myUpdater; private Comparator<? super NodeDescriptor<?>> myNodeDescriptorComparator; private final Comparator<TreeNode> myNodeComparator = new Comparator<>() { @Override public int compare(TreeNode n1, TreeNode n2) { if (isLoadingNode(n1) && isLoadingNode(n2)) return 0; if (isLoadingNode(n1)) return -1; if (isLoadingNode(n2)) return 1; NodeDescriptor<?> nodeDescriptor1 = getDescriptorFrom(n1); NodeDescriptor<?> nodeDescriptor2 = getDescriptorFrom(n2); if (nodeDescriptor1 == null && nodeDescriptor2 == null) return 0; if (nodeDescriptor1 == null) return -1; if (nodeDescriptor2 == null) return 1; return myNodeDescriptorComparator != null ? myNodeDescriptorComparator.compare(nodeDescriptor1, nodeDescriptor2) : nodeDescriptor1.getIndex() - nodeDescriptor2.getIndex(); } }; long myOwnComparatorStamp; private long myLastComparatorStamp; private DefaultMutableTreeNode myRootNode; private final Map<Object, Object> myElementToNodeMap = new HashMap<>(); private final Set<DefaultMutableTreeNode> myUnbuiltNodes = new HashSet<>(); private TreeExpansionListener myExpansionListener; private MySelectionListener mySelectionListener; private final QueueProcessor<Runnable> myWorker = new QueueProcessor<>(runnable -> { runnable.run(); TimeoutUtil.sleep(1); }); private final Set<Runnable> myActiveWorkerTasks = new HashSet<>(); private ProgressIndicator myProgress; private AbstractTreeNode<Object> TREE_NODE_WRAPPER; private boolean myRootNodeWasQueuedToInitialize; private boolean myRootNodeInitialized; private final Map<Object, List<NodeAction>> myNodeActions = new HashMap<>(); private boolean myUpdateFromRootRequested; private boolean myWasEverShown; private boolean myUpdateIfInactive; private final Map<Object, UpdateInfo> myLoadedInBackground = new HashMap<>(); private final Map<Object, List<NodeAction>> myNodeChildrenActions = new HashMap<>(); private long myClearOnHideDelay = -1; private volatile long ourUi2Countdown; private final Set<Runnable> myDeferredSelections = new HashSet<>(); private final Set<Runnable> myDeferredExpansions = new HashSet<>(); private boolean myCanProcessDeferredSelections; private UpdaterTreeState myUpdaterState; private AbstractTreeBuilder myBuilder; private final Set<DefaultMutableTreeNode> myUpdatingChildren = new HashSet<>(); private boolean myCanYield; private final List<TreeUpdatePass> myYieldingPasses = new ArrayList<>(); private boolean myYieldingNow; private final Set<DefaultMutableTreeNode> myPendingNodeActions = new HashSet<>(); private final Set<Runnable> myYieldingDoneRunnables = new HashSet<>(); private final Alarm myBusyAlarm = new Alarm(); private final Runnable myWaiterForReady = new TreeRunnable("AbstractTreeUi.myWaiterForReady") { @Override public void perform() { maybeSetBusyAndScheduleWaiterForReady(false, null); } }; private final RegistryValue myYieldingUpdate = Registry.get("ide.tree.yieldingUiUpdate"); private final RegistryValue myShowBusyIndicator = Registry.get("ide.tree.showBusyIndicator"); private final RegistryValue myWaitForReadyTime = Registry.get("ide.tree.waitForReadyTimeout"); private boolean myWasEverIndexNotReady; private boolean myShowing; private final FocusAdapter myFocusListener = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { maybeReady(); } }; private final Set<DefaultMutableTreeNode> myNotForSmartExpand = new HashSet<>(); private TreePath myRequestedExpand; private TreePath mySilentExpand; private TreePath mySilentSelect; private final ActionCallback myInitialized = new ActionCallback(); private final BusyObject.Impl myBusyObject = new BusyObject.Impl() { @Override public boolean isReady() { return AbstractTreeUi.this.isReady(true); } @Override protected void onReadyWasSent() { removeActivity(); } }; private boolean myPassThroughMode; private final Set<Object> myAutoExpandRoots = new HashSet<>(); private final RegistryValue myAutoExpandDepth = Registry.get("ide.tree.autoExpandMaxDepth"); private final Set<DefaultMutableTreeNode> myWillBeExpanded = new HashSet<>(); private SimpleTimerTask myCleanupTask; private final AtomicBoolean myCancelRequest = new AtomicBoolean(); private final ReentrantLock myStateLock = new ReentrantLock(); private final AtomicBoolean myResettingToReadyNow = new AtomicBoolean(); private final Map<Progressive, ProgressIndicator> myBatchIndicators = new HashMap<>(); private final Map<Progressive, ActionCallback> myBatchCallbacks = new HashMap<>(); private final Map<DefaultMutableTreeNode, DefaultMutableTreeNode> myCancelledBuild = new WeakHashMap<>(); private boolean mySelectionIsAdjusted; private boolean myReleaseRequested; private boolean mySelectionIsBeingAdjusted; private final Set<Object> myRevalidatedObjects = new HashSet<>(); private final Set<Runnable> myUserRunnables = new HashSet<>(); private UiActivityMonitor myActivityMonitor; @NonNls private UiActivity myActivityId; @Override public String toString() { return "AbstractTreeUi: builder = " + myBuilder; } protected void init(@NotNull AbstractTreeBuilder builder, @NotNull JTree tree, @NotNull DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, @Nullable Comparator<? super NodeDescriptor<?>> comparator, boolean updateIfInactive) { myBuilder = builder; myTree = tree; myTreeModel = treeModel; myActivityMonitor = UiActivityMonitor.getInstance(); myActivityId = new UiActivity.AsyncBgOperation("TreeUi " + this); addModelListenerToDiagnoseAccessOutsideEdt(); TREE_NODE_WRAPPER = AbstractTreeBuilder.createSearchingTreeNodeWrapper(); myTree.setModel(myTreeModel); setRootNode((DefaultMutableTreeNode)treeModel.getRoot()); myTreeStructure = treeStructure; myNodeDescriptorComparator = comparator; myUpdateIfInactive = updateIfInactive; UIUtil.invokeLaterIfNeeded(new TreeRunnable("AbstractTreeUi.init") { @Override public void perform() { if (!wasRootNodeInitialized()) { if (myRootNode.getChildCount() == 0) { insertLoadingNode(myRootNode, true); } } } }); myExpansionListener = new MyExpansionListener(); myTree.addTreeExpansionListener(myExpansionListener); mySelectionListener = new MySelectionListener(); myTree.addTreeSelectionListener(mySelectionListener); setUpdater(getBuilder().createUpdater()); myProgress = getBuilder().createProgressIndicator(); Disposer.register(getBuilder(), getUpdater()); if (myProgress != null) { Disposer.register(getBuilder(), () -> myProgress.cancel()); } final UiNotifyConnector uiNotify = new UiNotifyConnector(tree, new Activatable() { @Override public void showNotify() { myShowing = true; myWasEverShown = true; if (canInitiateNewActivity()) { activate(true); } } @Override public void hideNotify() { myShowing = false; if (canInitiateNewActivity()) { deactivate(); } } }); Disposer.register(getBuilder(), uiNotify); myTree.addFocusListener(myFocusListener); } private boolean isNodeActionsPending() { return !myNodeActions.isEmpty() || !myNodeChildrenActions.isEmpty(); } private void clearNodeActions() { myNodeActions.clear(); myNodeChildrenActions.clear(); } private void maybeSetBusyAndScheduleWaiterForReady(boolean forcedBusy, @Nullable Object element) { if (!myShowBusyIndicator.asBoolean()) return; boolean canUpdateBusyState = false; if (forcedBusy) { if (canYield() || isToBuildChildrenInBackground(element)) { canUpdateBusyState = true; } } else { canUpdateBusyState = true; } if (!canUpdateBusyState) return; if (myTree instanceof Tree) { final Tree tree = (Tree)myTree; final boolean isBusy = !isReady(true) || forcedBusy; if (isBusy && tree.isShowing()) { tree.setPaintBusy(true); myBusyAlarm.cancelAllRequests(); myBusyAlarm.addRequest(myWaiterForReady, myWaitForReadyTime.asInteger()); } else { tree.setPaintBusy(false); } } } private void setHoldSize(boolean holdSize) { if (myTree instanceof Tree) { final Tree tree = (Tree)myTree; tree.setHoldSize(holdSize); } } private void cleanUpAll() { final long now = System.currentTimeMillis(); final long timeToCleanup = ourUi2Countdown; if (timeToCleanup != 0 && now >= timeToCleanup) { ourUi2Countdown = 0; Runnable runnable = new TreeRunnable("AbstractTreeUi.cleanUpAll") { @Override public void perform() { if (!canInitiateNewActivity()) return; myCleanupTask = null; getBuilder().cleanUp(); } }; if (isPassthroughMode()) { runnable.run(); } else { invokeLaterIfNeeded(false, runnable); } } } void doCleanUp() { Runnable cleanup = new TreeRunnable("AbstractTreeUi.doCleanUp") { @Override public void perform() { if (canInitiateNewActivity()) { cleanUpNow(); } } }; if (isPassthroughMode()) { cleanup.run(); } else { invokeLaterIfNeeded(false, cleanup); } } void invokeLaterIfNeeded(boolean forceEdt, @NotNull final Runnable runnable) { Runnable actual = new TreeRunnable("AbstractTreeUi.invokeLaterIfNeeded") { @Override public void perform() { if (!isReleased()) { runnable.run(); } } }; if (isPassthroughMode() || !forceEdt && !isEdt() && !isTreeShowing() && !myWasEverShown) { actual.run(); } else { UIUtil.invokeLaterIfNeeded(actual); } } public void activate(boolean byShowing) { cancelCurrentCleanupTask(); myCanProcessDeferredSelections = true; ourUi2Countdown = 0; if (!myWasEverShown || myUpdateFromRootRequested || myUpdateIfInactive) { getBuilder().updateFromRoot(); } getUpdater().showNotify(); myWasEverShown |= byShowing; } private void cancelCurrentCleanupTask() { if (myCleanupTask != null) { myCleanupTask.cancel(); myCleanupTask = null; } } void deactivate() { getUpdater().hideNotify(); myBusyAlarm.cancelAllRequests(); if (!myWasEverShown) return; // ask for termination of background children calculation if (myProgress != null && myProgress.isRunning()) myProgress.cancel(); if (!isReady()) { cancelUpdate(); myUpdateFromRootRequested = true; } if (getClearOnHideDelay() >= 0) { ourUi2Countdown = System.currentTimeMillis() + getClearOnHideDelay(); scheduleCleanUpAll(); } } private void scheduleCleanUpAll() { cancelCurrentCleanupTask(); myCleanupTask = SimpleTimer.getInstance().setUp(new TreeRunnable("AbstractTreeUi.scheduleCleanUpAll") { @Override public void perform() { cleanUpAll(); } }, getClearOnHideDelay()); } void requestRelease() { myReleaseRequested = true; cancelUpdate().doWhenDone(new TreeRunnable("AbstractTreeUi.requestRelease: on done") { @Override public void perform() { releaseNow(); } }); } public ProgressIndicator getProgress() { return myProgress; } private void releaseNow() { try (LockToken ignored = acquireLock()) { myTree.removeTreeExpansionListener(myExpansionListener); myTree.removeTreeSelectionListener(mySelectionListener); myTree.removeFocusListener(myFocusListener); disposeNode(getRootNode()); myElementToNodeMap.clear(); getUpdater().cancelAllRequests(); myWorker.clear(); clearWorkerTasks(); TREE_NODE_WRAPPER.setValue(null); if (myProgress != null) { myProgress.cancel(); } cancelCurrentCleanupTask(); myTree = null; setUpdater(null); myTreeStructure = null; myBuilder.releaseUi(); myBuilder = null; clearNodeActions(); myDeferredSelections.clear(); myDeferredExpansions.clear(); myYieldingDoneRunnables.clear(); } } public boolean isReleased() { return myBuilder == null; } void doExpandNodeChildren(@NotNull final DefaultMutableTreeNode node) { if (!myUnbuiltNodes.contains(node)) return; if (isLoadedInBackground(getElementFor(node))) return; AbstractTreeStructure structure = getTreeStructure(); structure.asyncCommit().doWhenDone(new TreeRunnable("AbstractTreeUi.doExpandNodeChildren") { @Override public void perform() { addSubtreeToUpdate(node); // at this point some tree updates may already have been run as a result of // in tests these updates may lead to the instance disposal, so getUpdater() at the next line may return null final AbstractTreeUpdater updater = getUpdater(); if (updater != null) { updater.performUpdate(); } } }); //if (structure.hasSomethingToCommit()) structure.commit(); } public final AbstractTreeStructure getTreeStructure() { return myTreeStructure; } public final JTree getTree() { return myTree; } @Nullable private static NodeDescriptor getDescriptorFrom(Object node) { if (node instanceof DefaultMutableTreeNode) { Object userObject = ((DefaultMutableTreeNode)node).getUserObject(); if (userObject instanceof NodeDescriptor) { return (NodeDescriptor)userObject; } } return null; } @Nullable public final DefaultMutableTreeNode getNodeForElement(@NotNull Object element, final boolean validateAgainstStructure) { DefaultMutableTreeNode result = null; if (validateAgainstStructure) { int index = 0; while (true) { final DefaultMutableTreeNode node = findNode(element, index); if (node == null) break; if (isNodeValidForElement(element, node)) { result = node; break; } index++; } } else { result = getFirstNode(element); } if (result != null && !isNodeInStructure(result)) { disposeNode(result); result = null; } return result; } private boolean isNodeInStructure(@NotNull DefaultMutableTreeNode node) { return TreeUtil.isAncestor(getRootNode(), node) && getRootNode() == myTreeModel.getRoot(); } private boolean isNodeValidForElement(@NotNull final Object element, @NotNull final DefaultMutableTreeNode node) { return isSameHierarchy(element, node) || isValidChildOfParent(element, node); } private boolean isValidChildOfParent(@NotNull final Object element, @NotNull final DefaultMutableTreeNode node) { final DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); final Object parentElement = getElementFor(parent); if (!isInStructure(parentElement)) return false; if (parent instanceof ElementNode) { return ((ElementNode)parent).isValidChild(element); } for (int i = 0; i < parent.getChildCount(); i++) { final TreeNode child = parent.getChildAt(i); final Object eachElement = getElementFor(child); if (element.equals(eachElement)) return true; } return false; } private boolean isSameHierarchy(@NotNull Object element, @NotNull DefaultMutableTreeNode node) { Object eachParent = element; DefaultMutableTreeNode eachParentNode = node; boolean valid; while (true) { if (eachParent == null) { valid = eachParentNode == null; break; } if (!eachParent.equals(getElementFor(eachParentNode))) { valid = false; break; } eachParent = getTreeStructure().getParentElement(eachParent); eachParentNode = (DefaultMutableTreeNode)eachParentNode.getParent(); } return valid; } @Nullable public final DefaultMutableTreeNode getNodeForPath(Object @NotNull [] path) { DefaultMutableTreeNode node = null; for (final Object pathElement : path) { node = node == null ? getFirstNode(pathElement) : findNodeForChildElement(node, pathElement); if (node == null) { break; } } return node; } final void buildNodeForElement(@NotNull Object element) { getUpdater().performUpdate(); DefaultMutableTreeNode node = getNodeForElement(element, false); if (node == null) { final List<Object> elements = new ArrayList<>(); while (true) { element = getTreeStructure().getParentElement(element); if (element == null) { break; } elements.add(0, element); } for (final Object element1 : elements) { node = getNodeForElement(element1, false); if (node != null) { expand(node, true); } } } } public final void buildNodeForPath(Object @NotNull [] path) { getUpdater().performUpdate(); DefaultMutableTreeNode node = null; for (final Object pathElement : path) { node = node == null ? getFirstNode(pathElement) : findNodeForChildElement(node, pathElement); if (node != null && node != path[path.length - 1]) { expand(node, true); } } } public final void setNodeDescriptorComparator(Comparator<? super NodeDescriptor<?>> nodeDescriptorComparator) { myNodeDescriptorComparator = nodeDescriptorComparator; myLastComparatorStamp = -1; getBuilder().queueUpdateFrom(getTreeStructure().getRootElement(), true); } @NotNull protected AbstractTreeBuilder getBuilder() { return myBuilder; } protected final void initRootNode() { if (myUpdateIfInactive) { activate(false); } else { myUpdateFromRootRequested = true; } } private boolean initRootNodeNowIfNeeded(@NotNull final TreeUpdatePass pass) { boolean wasCleanedUp = false; if (myRootNodeWasQueuedToInitialize) { Object root = getTreeStructure().getRootElement(); Object currentRoot = getElementFor(myRootNode); if (Comparing.equal(root, currentRoot)) return false; Object rootAgain = getTreeStructure().getRootElement(); if (root != rootAgain && !root.equals(rootAgain)) { assert false : "getRootElement() if called twice must return either root1 == root2 or root1.equals(root2)"; } cleanUpNow(); wasCleanedUp = true; } if (myRootNodeWasQueuedToInitialize) return true; myRootNodeWasQueuedToInitialize = true; final Object rootElement = getTreeStructure().getRootElement(); addNodeAction(rootElement, false, node -> processDeferredActions()); final Ref<NodeDescriptor> rootDescriptor = new Ref<>(null); final boolean bgLoading = isToBuildChildrenInBackground(rootElement); Runnable build = new TreeRunnable("AbstractTreeUi.initRootNodeNowIfNeeded: build") { @Override public void perform() { rootDescriptor.set(getTreeStructure().createDescriptor(rootElement, null)); getRootNode().setUserObject(rootDescriptor.get()); update(rootDescriptor.get(), true); pass.addToUpdated(rootDescriptor.get()); } }; Runnable update = new TreeRunnable("AbstractTreeUi.initRootNodeNowIfNeeded: update") { @Override public void perform() { Object fromDescriptor = getElementFromDescriptor(rootDescriptor.get()); if (!isNodeNull(fromDescriptor)) { createMapping(fromDescriptor, getRootNode()); } insertLoadingNode(getRootNode(), true); boolean willUpdate = false; if (!rootDescriptor.isNull() && isAutoExpand(rootDescriptor.get())) { willUpdate = myUnbuiltNodes.contains(getRootNode()); expand(getRootNode(), true); } ActionCallback callback; if (willUpdate) { callback = ActionCallback.DONE; } else { callback = updateNodeChildren(getRootNode(), pass, null, false, false, false, true, true); } callback.doWhenDone(new TreeRunnable("AbstractTreeUi.initRootNodeNowIfNeeded: on done updateNodeChildren") { @Override public void perform() { if (getRootNode().getChildCount() == 0) { myTreeModel.nodeChanged(getRootNode()); } } }); } }; if (bgLoading) { queueToBackground(build, update) .onSuccess(new TreeConsumer<>("AbstractTreeUi.initRootNodeNowIfNeeded: on processed queueToBackground") { @Override public void perform() { invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.initRootNodeNowIfNeeded: on processed queueToBackground later") { @Override public void perform() { myRootNodeInitialized = true; processNodeActionsIfReady(myRootNode); } }); } }); } else { build.run(); update.run(); myRootNodeInitialized = true; processNodeActionsIfReady(myRootNode); } return wasCleanedUp; } private boolean isAutoExpand(@NotNull NodeDescriptor descriptor) { return isAutoExpand(descriptor, true); } private boolean isAutoExpand(@NotNull NodeDescriptor descriptor, boolean validate) { if (isAlwaysExpandedTree()) return false; boolean autoExpand = getBuilder().isAutoExpandNode(descriptor); Object element = getElementFromDescriptor(descriptor); if (validate && element != null) { autoExpand = validateAutoExpand(autoExpand, element); } if (!autoExpand && !myTree.isRootVisible()) { if (element != null && element.equals(getTreeStructure().getRootElement())) return true; } return autoExpand; } private boolean validateAutoExpand(boolean autoExpand, @NotNull Object element) { if (autoExpand) { int distance = getDistanceToAutoExpandRoot(element); if (distance < 0) { myAutoExpandRoots.add(element); } else { if (distance >= myAutoExpandDepth.asInteger() - 1) { autoExpand = false; } } if (autoExpand) { DefaultMutableTreeNode node = getNodeForElement(element, false); autoExpand = node != null && isInVisibleAutoExpandChain(node); } } return autoExpand; } private boolean isInVisibleAutoExpandChain(@NotNull DefaultMutableTreeNode child) { TreeNode eachParent = child; while (eachParent != null) { if (myRootNode == eachParent) return true; NodeDescriptor eachDescriptor = getDescriptorFrom(eachParent); if (eachDescriptor == null || !isAutoExpand(eachDescriptor, false)) { TreePath path = getPathFor(eachParent); return myWillBeExpanded.contains(path.getLastPathComponent()) || myTree.isExpanded(path) && myTree.isVisible(path); } eachParent = eachParent.getParent(); } return false; } private int getDistanceToAutoExpandRoot(@NotNull Object element) { int distance = 0; Object eachParent = element; while (eachParent != null) { if (myAutoExpandRoots.contains(eachParent)) break; eachParent = getTreeStructure().getParentElement(eachParent); distance++; } return eachParent != null ? distance : -1; } private boolean isAutoExpand(@NotNull DefaultMutableTreeNode node) { NodeDescriptor descriptor = getDescriptorFrom(node); return descriptor != null && isAutoExpand(descriptor); } private boolean isAlwaysExpandedTree() { return myTree instanceof AlwaysExpandedTree && ((AlwaysExpandedTree)myTree).isAlwaysExpanded(); } @NotNull private Promise<Boolean> update(@NotNull final NodeDescriptor nodeDescriptor, boolean now) { Promise<Boolean> promise; if (now || isPassthroughMode()) { promise = Promises.resolvedPromise(update(nodeDescriptor)); } else { final AsyncPromise<Boolean> result = new AsyncPromise<>(); promise = result; boolean bgLoading = isToBuildInBackground(nodeDescriptor); boolean edt = isEdt(); if (bgLoading) { if (edt) { final AtomicBoolean changes = new AtomicBoolean(); queueToBackground(new TreeRunnable("AbstractTreeUi.update: build") { @Override public void perform() { changes.set(update(nodeDescriptor)); } }, new TreeRunnable("AbstractTreeUi.update: post") { @Override public void perform() { result.setResult(changes.get()); } } ); } else { result.setResult(update(nodeDescriptor)); } } else { if (edt || !myWasEverShown) { result.setResult(update(nodeDescriptor)); } else { invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.update: later") { @Override public void perform() { execute(new TreeRunnable("AbstractTreeUi.update: later execute") { @Override public void perform() { result.setResult(update(nodeDescriptor)); } }); } }); } } } promise.onSuccess(changes -> { if (!changes) { return; } invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.update: on done result") { @Override public void perform() { Object element = nodeDescriptor.getElement(); DefaultMutableTreeNode node = element == null ? null : getNodeForElement(element, false); if (node != null) { TreePath path = getPathFor(node); if (myTree.isVisible(path)) { updateNodeImageAndPosition(node); } } } }); }); return promise; } private boolean update(@NotNull final NodeDescriptor nodeDescriptor) { while(true) { try (LockToken ignored = attemptLock()) { if (ignored == null) { // async children calculation is in progress under lock if (myProgress != null && myProgress.isRunning()) myProgress.cancel(); continue; } final AtomicBoolean update = new AtomicBoolean(); execute(new TreeRunnable("AbstractTreeUi.update") { @Override public void perform() { nodeDescriptor.setUpdateCount(nodeDescriptor.getUpdateCount() + 1); update.set(getBuilder().updateNodeDescriptor(nodeDescriptor)); } }); return update.get(); } catch (IndexNotReadyException e) { warnOnIndexNotReady(e); return false; } catch (InterruptedException e) { LOG.info(e); return false; } } } public void assertIsDispatchThread() { if (isPassthroughMode()) return; if ((isTreeShowing() || myWasEverShown) && !isEdt()) { LOG.error("Must be in event-dispatch thread"); } } private static boolean isEdt() { return SwingUtilities.isEventDispatchThread(); } private boolean isTreeShowing() { return myShowing; } private void assertNotDispatchThread() { if (isPassthroughMode()) return; if (isEdt()) { LOG.error("Must not be in event-dispatch thread"); } } private void processDeferredActions() { processDeferredActions(myDeferredSelections); processDeferredActions(myDeferredExpansions); } private static void processDeferredActions(@NotNull Set<Runnable> actions) { final Runnable[] runnables = actions.toArray(new Runnable[0]); actions.clear(); for (Runnable runnable : runnables) { runnable.run(); } } //todo: to make real callback @NotNull public ActionCallback queueUpdate(Object element) { return queueUpdate(element, true); } @NotNull public ActionCallback queueUpdate(final Object fromElement, boolean updateStructure) { assertIsDispatchThread(); try { if (getUpdater() == null) { return ActionCallback.REJECTED; } final ActionCallback result = new ActionCallback(); DefaultMutableTreeNode nodeToUpdate = null; boolean updateElementStructure = updateStructure; for (Object element = fromElement; element != null; element = getTreeStructure().getParentElement(element)) { final DefaultMutableTreeNode node = getFirstNode(element); if (node != null) { nodeToUpdate = node; break; } updateElementStructure = true; // always update children if element does not exist } addSubtreeToUpdate(nodeToUpdate != null? nodeToUpdate : getRootNode(), new TreeRunnable("AbstractTreeUi.queueUpdate") { @Override public void perform() { result.setDone(); } }, updateElementStructure); return result; } catch (ProcessCanceledException e) { return ActionCallback.REJECTED; } } public void doUpdateFromRoot() { updateSubtree(getRootNode(), false); } public final void updateSubtree(@NotNull DefaultMutableTreeNode node, boolean canSmartExpand) { updateSubtree(new TreeUpdatePass(node), canSmartExpand); } private void updateSubtree(@NotNull TreeUpdatePass pass, boolean canSmartExpand) { final AbstractTreeUpdater updater = getUpdater(); if (updater != null) { updater.addSubtreeToUpdate(pass); } else { updateSubtreeNow(pass, canSmartExpand); } } final void updateSubtreeNow(@NotNull TreeUpdatePass pass, boolean canSmartExpand) { maybeSetBusyAndScheduleWaiterForReady(true, getElementFor(pass.getNode())); setHoldSize(true); boolean consumed = initRootNodeNowIfNeeded(pass); if (consumed) return; final DefaultMutableTreeNode node = pass.getNode(); NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; if (pass.isUpdateStructure()) { setUpdaterState(new UpdaterTreeState(this)).beforeSubtreeUpdate(); boolean forceUpdate = true; TreePath path = getPathFor(node); boolean invisible = !myTree.isExpanded(path) && (path.getParentPath() == null || !myTree.isExpanded(path.getParentPath())); if (invisible && myUnbuiltNodes.contains(node)) { forceUpdate = false; } updateNodeChildren(node, pass, null, false, canSmartExpand, forceUpdate, false, pass.isUpdateChildren()); } else { updateRow(0, pass); } } private void updateRow(final int row, @NotNull final TreeUpdatePass pass) { LOG.debug("updateRow: ", row, " - ", pass); invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.updateRow") { @Override public void perform() { if (row >= getTree().getRowCount()) return; TreePath path = getTree().getPathForRow(row); if (path != null) { final NodeDescriptor descriptor = getDescriptorFrom(path.getLastPathComponent()); if (descriptor != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); maybeYield(() -> update(descriptor, false) .onSuccess(new TreeConsumer<>("AbstractTreeUi.updateRow: inner") { @Override public void perform() { updateRow(row + 1, pass); } }), pass, node); } } } }); } boolean isToBuildChildrenInBackground(Object element) { AbstractTreeStructure structure = getTreeStructure(); return element != null && structure.isToBuildChildrenInBackground(element); } private boolean isToBuildInBackground(NodeDescriptor descriptor) { return isToBuildChildrenInBackground(getElementFromDescriptor(descriptor)); } @NotNull private UpdaterTreeState setUpdaterState(@NotNull UpdaterTreeState state) { if (state.equals(myUpdaterState)) return state; final UpdaterTreeState oldState = myUpdaterState; if (oldState == null) { myUpdaterState = state; return state; } else { oldState.addAll(state); return oldState; } } void doUpdateNode(@NotNull final DefaultMutableTreeNode node) { NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; final Object prevElement = getElementFromDescriptor(descriptor); if (prevElement == null) return; update(descriptor, false) .onSuccess(changes -> { if (!isValid(descriptor)) { if (isInStructure(prevElement)) { Object toUpdate = ObjectUtils.notNull(getTreeStructure().getParentElement(prevElement), getTreeStructure().getRootElement()); getUpdater().addSubtreeToUpdateByElement(toUpdate); return; } } if (changes) { updateNodeImageAndPosition(node); } }); } public Object getElementFromDescriptor(NodeDescriptor descriptor) { return getBuilder().getTreeStructureElement(descriptor); } @NotNull private ActionCallback updateNodeChildren(@NotNull final DefaultMutableTreeNode node, @NotNull final TreeUpdatePass pass, @Nullable final LoadedChildren loadedChildren, final boolean forcedNow, final boolean toSmartExpand, final boolean forceUpdate, final boolean descriptorIsUpToDate, final boolean updateChildren) { AbstractTreeStructure treeStructure = getTreeStructure(); ActionCallback result = treeStructure.asyncCommit(); result.doWhenDone(new TreeRunnable("AbstractTreeUi.updateNodeChildren: on done") { @Override public void perform() { try { removeFromCancelled(node); execute(new TreeRunnable("AbstractTreeUi.updateNodeChildren: execute") { @Override public void perform() { doUpdateChildren(node, pass, loadedChildren, forcedNow, toSmartExpand, forceUpdate, descriptorIsUpToDate, updateChildren); } }); } catch (ProcessCanceledException e) { addToCancelled(node); throw e; } } }); return result; } private void doUpdateChildren(@NotNull final DefaultMutableTreeNode node, @NotNull final TreeUpdatePass pass, @Nullable final LoadedChildren loadedChildren, boolean forcedNow, final boolean toSmartExpand, boolean forceUpdate, boolean descriptorIsUpToDate, final boolean updateChildren) { try { final NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) { removeFromUnbuilt(node); removeLoading(node, true); return; } boolean descriptorIsReady = descriptorIsUpToDate || pass.isUpdated(descriptor); final boolean wasExpanded = myTree.isExpanded(new TreePath(node.getPath())) || isAutoExpand(node); final boolean wasLeaf = node.getChildCount() == 0; boolean bgBuild = isToBuildInBackground(descriptor); boolean requiredToUpdateChildren = forcedNow || wasExpanded; if (!requiredToUpdateChildren && forceUpdate) { boolean alwaysPlus = getBuilder().isAlwaysShowPlus(descriptor); if (alwaysPlus && wasLeaf) { requiredToUpdateChildren = true; } else { requiredToUpdateChildren = !alwaysPlus; if (!requiredToUpdateChildren && !myUnbuiltNodes.contains(node)) { removeChildren(node); } } } final AtomicReference<LoadedChildren> preloaded = new AtomicReference<>(loadedChildren); if (!requiredToUpdateChildren) { if (myUnbuiltNodes.contains(node) && node.getChildCount() == 0) { insertLoadingNode(node, true); } if (!descriptorIsReady) { update(descriptor, false); } return; } if (!forcedNow && !bgBuild && myUnbuiltNodes.contains(node)) { if (!descriptorIsReady) { update(descriptor, true); descriptorIsReady = true; } if (processAlwaysLeaf(node) || !updateChildren) { return; } Pair<Boolean, LoadedChildren> unbuilt = processUnbuilt(node, descriptor, pass, wasExpanded, null); if (unbuilt.getFirst()) { return; } preloaded.set(unbuilt.getSecond()); } final boolean childForceUpdate = isChildNodeForceUpdate(node, forceUpdate, wasExpanded); if (!forcedNow && isToBuildInBackground(descriptor)) { boolean alwaysLeaf = processAlwaysLeaf(node); queueBackgroundUpdate( new UpdateInfo(descriptor, pass, canSmartExpand(node, toSmartExpand), wasExpanded, childForceUpdate, descriptorIsReady, !alwaysLeaf && updateChildren), node); } else { if (!descriptorIsReady) { update(descriptor, false) .onSuccess(new TreeConsumer<>("AbstractTreeUi.doUpdateChildren") { @Override public void perform() { if (processAlwaysLeaf(node) || !updateChildren) return; updateNodeChildrenNow(node, pass, preloaded.get(), toSmartExpand, wasExpanded, childForceUpdate); } }); } else { if (processAlwaysLeaf(node) || !updateChildren) return; updateNodeChildrenNow(node, pass, preloaded.get(), toSmartExpand, wasExpanded, childForceUpdate); } } } finally { if (!isReleased()) { processNodeActionsIfReady(node); } } } private boolean processAlwaysLeaf(@NotNull DefaultMutableTreeNode node) { Object element = getElementFor(node); NodeDescriptor desc = getDescriptorFrom(node); if (desc == null) return false; if (element != null && getTreeStructure().isAlwaysLeaf(element)) { removeFromUnbuilt(node); removeLoading(node, true); if (node.getChildCount() > 0) { final TreeNode[] children = new TreeNode[node.getChildCount()]; for (int i = 0; i < node.getChildCount(); i++) { children[i] = node.getChildAt(i); } if (isSelectionInside(node)) { addSelectionPath(getPathFor(node), true, Conditions.alwaysTrue(), null); } processInnerChange(new TreeRunnable("AbstractTreeUi.processAlwaysLeaf") { @Override public void perform() { for (TreeNode each : children) { removeNodeFromParent((MutableTreeNode)each, true); disposeNode((DefaultMutableTreeNode)each); } } }); } removeFromUnbuilt(node); desc.setWasDeclaredAlwaysLeaf(true); processNodeActionsIfReady(node); return true; } else { boolean wasLeaf = desc.isWasDeclaredAlwaysLeaf(); desc.setWasDeclaredAlwaysLeaf(false); if (wasLeaf) { insertLoadingNode(node, true); } return false; } } private boolean isChildNodeForceUpdate(@NotNull DefaultMutableTreeNode node, boolean parentForceUpdate, boolean parentExpanded) { TreePath path = getPathFor(node); return parentForceUpdate && (parentExpanded || myTree.isExpanded(path)); } private void updateNodeChildrenNow(@NotNull final DefaultMutableTreeNode node, @NotNull final TreeUpdatePass pass, @Nullable final LoadedChildren preloadedChildren, final boolean toSmartExpand, final boolean wasExpanded, final boolean forceUpdate) { if (isUpdatingChildrenNow(node)) return; if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } final NodeDescriptor descriptor = getDescriptorFrom(node); final MutualMap<Object, Integer> elementToIndexMap = loadElementsFromStructure(descriptor, preloadedChildren); final LoadedChildren loadedChildren = preloadedChildren != null ? preloadedChildren : new LoadedChildren(elementToIndexMap.getKeys().toArray()); addToUpdatingChildren(node); pass.setCurrentNode(node); final boolean canSmartExpand = canSmartExpand(node, toSmartExpand); removeFromUnbuilt(node); //noinspection unchecked processExistingNodes(node, elementToIndexMap, pass, canSmartExpand(node, toSmartExpand), forceUpdate, wasExpanded, preloadedChildren) .onSuccess(new TreeConsumer("AbstractTreeUi.updateNodeChildrenNow: on done processExistingNodes") { @Override public void perform() { if (isDisposed(node)) { removeFromUpdatingChildren(node); return; } removeLoading(node, false); final boolean expanded = isExpanded(node, wasExpanded); if (expanded) { myWillBeExpanded.add(node); } else { myWillBeExpanded.remove(node); } collectNodesToInsert(descriptor, elementToIndexMap, node, expanded, loadedChildren) .doWhenDone((Consumer<List<TreeNode>>)nodesToInsert -> { insertNodesInto(nodesToInsert, node); ActionCallback callback = updateNodesToInsert(nodesToInsert, pass, canSmartExpand, isChildNodeForceUpdate(node, forceUpdate, expanded)); callback.doWhenDone(new TreeRunnable("AbstractTreeUi.updateNodeChildrenNow: on done updateNodesToInsert") { @Override public void perform() { removeLoading(node, false); removeFromUpdatingChildren(node); if (node.getChildCount() > 0) { if (expanded) { expand(node, canSmartExpand); } } if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } final Object element = getElementFor(node); addNodeAction(element, false, node1 -> removeLoading(node1, false)); processNodeActionsIfReady(node); } }); }).doWhenProcessed(new TreeRunnable("AbstractTreeUi.updateNodeChildrenNow: on processed collectNodesToInsert") { @Override public void perform() { myWillBeExpanded.remove(node); removeFromUpdatingChildren(node); processNodeActionsIfReady(node); } }); } }) .onError(new TreeConsumer<>("AbstractTreeUi.updateNodeChildrenNow: on reject processExistingNodes") { @Override public void perform() { removeFromUpdatingChildren(node); processNodeActionsIfReady(node); } }); } private boolean isDisposed(@NotNull DefaultMutableTreeNode node) { return !node.isNodeAncestor((DefaultMutableTreeNode)myTree.getModel().getRoot()); } private void expandSilently(TreePath path) { assertIsDispatchThread(); try { mySilentExpand = path; getTree().expandPath(path); } finally { mySilentExpand = null; } } private void addSelectionSilently(TreePath path) { assertIsDispatchThread(); try { mySilentSelect = path; getTree().getSelectionModel().addSelectionPath(path); } finally { mySilentSelect = null; } } private void expand(@NotNull DefaultMutableTreeNode node, boolean canSmartExpand) { expand(new TreePath(node.getPath()), canSmartExpand); } private void expand(@NotNull final TreePath path, boolean canSmartExpand) { final Object last = path.getLastPathComponent(); boolean isLeaf = myTree.getModel().isLeaf(path.getLastPathComponent()); final boolean isRoot = last == myTree.getModel().getRoot(); final TreePath parent = path.getParentPath(); if (isRoot && !myTree.isExpanded(path)) { if (myTree.isRootVisible() || myUnbuiltNodes.contains(last)) { insertLoadingNode((DefaultMutableTreeNode)last, false); } expandPath(path, canSmartExpand); } else if (myTree.isExpanded(path) || isLeaf && parent != null && myTree.isExpanded(parent) && !myUnbuiltNodes.contains(last) && !isCancelled(last)) { if (last instanceof DefaultMutableTreeNode) { processNodeActionsIfReady((DefaultMutableTreeNode)last); } } else { if (isLeaf && (myUnbuiltNodes.contains(last) || isCancelled(last))) { insertLoadingNode((DefaultMutableTreeNode)last, true); expandPath(path, canSmartExpand); } else if (isLeaf && parent != null) { final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)parent.getLastPathComponent(); if (parentNode != null) { addToUnbuilt(parentNode); } expandPath(parent, canSmartExpand); } else { expandPath(path, canSmartExpand); } } } private void addToUnbuilt(DefaultMutableTreeNode node) { myUnbuiltNodes.add(node); } private void removeFromUnbuilt(DefaultMutableTreeNode node) { myUnbuiltNodes.remove(node); } private Pair<Boolean, LoadedChildren> processUnbuilt(@NotNull final DefaultMutableTreeNode node, final NodeDescriptor descriptor, @NotNull final TreeUpdatePass pass, final boolean isExpanded, @Nullable final LoadedChildren loadedChildren) { final Ref<Pair<Boolean, LoadedChildren>> result = new Ref<>(); execute(new TreeRunnable("AbstractTreeUi.processUnbuilt") { @Override public void perform() { if (!isExpanded && getBuilder().isAlwaysShowPlus(descriptor)) { result.set(new Pair<>(true, null)); return; } final Object element = getElementFor(node); if (element == null) { trace("null element for node " + node); result.set(new Pair<>(true, null)); return; } addToUpdatingChildren(node); try { final LoadedChildren children = loadedChildren != null ? loadedChildren : new LoadedChildren(getChildrenFor(element)); boolean processed; if (children.getElements().isEmpty()) { removeFromUnbuilt(node); removeLoading(node, true); processed = true; } else { if (isAutoExpand(node)) { addNodeAction(getElementFor(node), false, node1 -> { final TreePath path = new TreePath(node1.getPath()); if (getTree().isExpanded(path) || children.getElements().isEmpty()) { removeLoading(node1, false); } else { maybeYield(() -> { expand(element, null); return Promises.resolvedPromise(); }, pass, node1); } }); } processed = false; } removeFromUpdatingChildren(node); processNodeActionsIfReady(node); result.set(new Pair<>(processed, children)); } finally { removeFromUpdatingChildren(node); } } }); return result.get(); } private boolean removeIfLoading(@NotNull TreeNode node) { if (isLoadingNode(node)) { moveSelectionToParentIfNeeded(node); removeNodeFromParent((MutableTreeNode)node, false); return true; } return false; } private void moveSelectionToParentIfNeeded(@NotNull TreeNode node) { TreePath path = getPathFor(node); if (myTree.getSelectionModel().isPathSelected(path)) { TreePath parentPath = path.getParentPath(); myTree.getSelectionModel().removeSelectionPath(path); if (parentPath != null) { myTree.getSelectionModel().addSelectionPath(parentPath); } } } //todo [kirillk] temporary consistency check private Object[] getChildrenFor(final Object element) { final Ref<Object[]> passOne = new Ref<>(); try (LockToken ignored = acquireLock()) { execute(new TreeRunnable("AbstractTreeUi.getChildrenFor") { @Override public void perform() { passOne.set(getTreeStructure().getChildElements(element)); } }); } catch (IndexNotReadyException e) { warnOnIndexNotReady(e); return ArrayUtilRt.EMPTY_OBJECT_ARRAY; } if (!Registry.is("ide.tree.checkStructure")) return passOne.get(); final Object[] passTwo = getTreeStructure().getChildElements(element); Set<Object> two = ContainerUtil.set(passTwo); if (passOne.get().length != passTwo.length) { LOG.error( "AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element); } else { for (Object eachInOne : passOne.get()) { if (!two.contains(eachInOne)) { LOG.error( "AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element); break; } } } return passOne.get(); } private void warnOnIndexNotReady(IndexNotReadyException e) { if (!myWasEverIndexNotReady) { myWasEverIndexNotReady = true; LOG.error("Tree is not dumb-mode-aware; treeBuilder=" + getBuilder() + " treeStructure=" + getTreeStructure(), e); } } @NotNull private ActionCallback updateNodesToInsert(@NotNull final List<? extends TreeNode> nodesToInsert, @NotNull TreeUpdatePass pass, boolean canSmartExpand, boolean forceUpdate) { ActionCallback.Chunk chunk = new ActionCallback.Chunk(); for (TreeNode node : nodesToInsert) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode)node; ActionCallback callback = updateNodeChildren(childNode, pass, null, false, canSmartExpand, forceUpdate, true, true); if (!callback.isDone()) { chunk.add(callback); } } return chunk.getWhenProcessed(); } @NotNull private Promise<?> processExistingNodes(@NotNull final DefaultMutableTreeNode node, @NotNull final MutualMap<Object, Integer> elementToIndexMap, @NotNull final TreeUpdatePass pass, final boolean canSmartExpand, final boolean forceUpdate, final boolean wasExpanded, @Nullable final LoadedChildren preloaded) { final List<TreeNode> childNodes = TreeUtil.listChildren(node); return maybeYield(() -> { if (pass.isExpired()) return Promises.<Void>rejectedPromise(); if (childNodes.isEmpty()) return Promises.resolvedPromise(); List<Promise<?>> promises = new SmartList<>(); for (TreeNode each : childNodes) { final DefaultMutableTreeNode eachChild = (DefaultMutableTreeNode)each; if (isLoadingNode(eachChild)) { continue; } final boolean childForceUpdate = isChildNodeForceUpdate(eachChild, forceUpdate, wasExpanded); promises.add(maybeYield(() -> { NodeDescriptor descriptor = preloaded != null ? preloaded.getDescriptor(getElementFor(eachChild)) : null; NodeDescriptor descriptorFromNode = getDescriptorFrom(eachChild); if (isValid(descriptor)) { eachChild.setUserObject(descriptor); if (descriptorFromNode != null) { descriptor.setChildrenSortingStamp(descriptorFromNode.getChildrenSortingStamp()); } } else { descriptor = descriptorFromNode; } return processExistingNode(eachChild, descriptor, node, elementToIndexMap, pass, canSmartExpand, childForceUpdate, preloaded); }, pass, node)); for (Promise<?> promise : promises) { if (promise.getState() == Promise.State.REJECTED) { return Promises.<Void>rejectedPromise(); } } } return Promises.all(promises); }, pass, node); } private boolean isRerunNeeded(@NotNull TreeUpdatePass pass) { if (pass.isExpired() || !canInitiateNewActivity()) return false; final boolean rerunBecauseTreeIsHidden = !pass.isExpired() && !isTreeShowing() && getUpdater().isInPostponeMode(); return rerunBecauseTreeIsHidden || getUpdater().isRerunNeededFor(pass); } public static <T> T calculateYieldingToWriteAction(@NotNull Supplier<? extends T> producer) throws ProcessCanceledException { if (!Registry.is("ide.abstractTreeUi.BuildChildrenInBackgroundYieldingToWriteAction") || ApplicationManager.getApplication().isDispatchThread()) { return producer.get(); } ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null && indicator.isRunning()) { return producer.get(); } Ref<T> result = new Ref<>(); boolean succeeded = ProgressManager.getInstance().runInReadActionWithWriteActionPriority( () -> result.set(producer.get()), indicator ); if (!succeeded || indicator != null && indicator.isCanceled()) { throw new ProcessCanceledException(); } return result.get(); } @FunctionalInterface private interface AsyncRunnable { @NotNull Promise<?> run(); } @NotNull private Promise<?> maybeYield(@NotNull final AsyncRunnable processRunnable, @NotNull final TreeUpdatePass pass, final DefaultMutableTreeNode node) { if (isRerunNeeded(pass)) { getUpdater().requeue(pass); return Promises.<Void>rejectedPromise(); } if (canYield()) { final AsyncPromise<?> result = new AsyncPromise<Void>(); pass.setCurrentNode(node); boolean wasRun = yieldAndRun(new TreeRunnable("AbstractTreeUi.maybeYeild") { @Override public void perform() { if (pass.isExpired()) { result.setError("expired"); return; } if (isRerunNeeded(pass)) { runDone(new TreeRunnable("AbstractTreeUi.maybeYeild: rerun") { @Override public void perform() { if (!pass.isExpired()) { queueUpdate(getElementFor(node)); } } }); result.setError("requeue"); } else { try { //noinspection unchecked execute(processRunnable).processed((Promise)result); } catch (ProcessCanceledException e) { pass.expire(); cancelUpdate(); result.setError("rejected"); } } } }, pass); if (!wasRun) { result.setError("rejected"); } return result; } else { try { return execute(processRunnable); } catch (ProcessCanceledException e) { pass.expire(); cancelUpdate(); return Promises.<Void>rejectedPromise(); } } } @NotNull private Promise<?> execute(@NotNull AsyncRunnable runnable) throws ProcessCanceledException { try { if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } Promise<?> promise = runnable.run(); if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } return promise; } catch (ProcessCanceledException e) { if (!isReleased()) { setCancelRequested(true); resetToReady(); } throw e; } } private void execute(@NotNull Runnable runnable) throws ProcessCanceledException { try { if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } runnable.run(); if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } } catch (ProcessCanceledException e) { if (!isReleased()) { setCancelRequested(true); resetToReady(); } throw e; } } private boolean canInitiateNewActivity() { return !isCancelProcessed() && !myReleaseRequested && !isReleased(); } private void resetToReady() { if (isReady()) { return; } if (myResettingToReadyNow.get()) { _getReady(); return; } myResettingToReadyNow.set(true); invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.resetToReady: later") { @Override public void perform() { if (!myResettingToReadyNow.get()) { return; } Progressive[] progressives = myBatchIndicators.keySet().toArray(new Progressive[0]); for (Progressive each : progressives) { myBatchIndicators.remove(each).cancel(); myBatchCallbacks.remove(each).setRejected(); } resetToReadyNow(); } }); } @NotNull private ActionCallback resetToReadyNow() { if (isReleased()) return ActionCallback.REJECTED; assertIsDispatchThread(); DefaultMutableTreeNode[] uc; synchronized (myUpdatingChildren) { uc = myUpdatingChildren.toArray(new DefaultMutableTreeNode[0]); } for (DefaultMutableTreeNode each : uc) { resetIncompleteNode(each); } Object[] bg = ArrayUtil.toObjectArray(myLoadedInBackground.keySet()); for (Object each : bg) { final DefaultMutableTreeNode node = getNodeForElement(each, false); if (node != null) { resetIncompleteNode(node); } } myUpdaterState = null; getUpdater().reset(); myYieldingNow = false; myYieldingPasses.clear(); myYieldingDoneRunnables.clear(); myNodeActions.clear(); myNodeChildrenActions.clear(); synchronized (myUpdatingChildren) { myUpdatingChildren.clear(); } myLoadedInBackground.clear(); myDeferredExpansions.clear(); myDeferredSelections.clear(); ActionCallback result = _getReady(); result.doWhenDone(new TreeRunnable("AbstractTreeUi.resetToReadyNow: on done") { @Override public void perform() { myResettingToReadyNow.set(false); setCancelRequested(false); } }); maybeReady(); return result; } void addToCancelled(@NotNull DefaultMutableTreeNode node) { myCancelledBuild.put(node, node); } private void removeFromCancelled(@NotNull DefaultMutableTreeNode node) { myCancelledBuild.remove(node); } public boolean isCancelled(@NotNull Object node) { return node instanceof DefaultMutableTreeNode && myCancelledBuild.containsKey(node); } private void resetIncompleteNode(@NotNull DefaultMutableTreeNode node) { if (myReleaseRequested) return; addToCancelled(node); if (!isExpanded(node, false)) { node.removeAllChildren(); Object element = getElementFor(node); if (element != null && !getTreeStructure().isAlwaysLeaf(element)) { insertLoadingNode(node, true); } } else { removeFromUnbuilt(node); removeLoading(node, true); } } private boolean yieldAndRun(@NotNull final Runnable runnable, @NotNull final TreeUpdatePass pass) { myYieldingPasses.add(pass); myYieldingNow = true; yieldToEDT(new TreeRunnable("AbstractTreeUi.yieldAndRun") { @Override public void perform() { if (isReleased()) return; runOnYieldingDone(new TreeRunnable("AbstractTreeUi.yieldAndRun: inner") { @Override public void perform() { if (isReleased()) return; executeYieldingRequest(runnable, pass); } }); } }); return true; } private boolean isYeildingNow() { return myYieldingNow; } private boolean hasScheduledUpdates() { return getUpdater().hasNodesToUpdate(); } public boolean isReady() { return isReady(false); } boolean isCancelledReady() { return isReady(false) && !myCancelledBuild.isEmpty(); } public boolean isReady(boolean attempt) { if (attempt && myStateLock.isLocked()) return false; Boolean ready = checkValue(() -> isIdle() && !hasPendingWork() && !isNodeActionsPending(), attempt); return ready != null && ready.booleanValue(); } @Nullable private Boolean checkValue(@NotNull Computable<Boolean> computable, boolean attempt) { try (LockToken ignored = attempt ? attemptLock() : acquireLock()) { return computable.compute(); } catch (InterruptedException e) { LOG.info(e); return null; } } @NotNull @NonNls public String getStatus() { return "isReady=" + isReady() + "\n" + " isIdle=" + isIdle() + "\n" + " isYeildingNow=" + isYeildingNow() + "\n" + " isWorkerBusy=" + isWorkerBusy() + "\n" + " hasUpdatingChildrenNow=" + hasUpdatingChildrenNow() + "\n" + " isLoadingInBackgroundNow=" + isLoadingInBackgroundNow() + "\n" + " hasPendingWork=" + hasPendingWork() + "\n" + " hasNodesToUpdate=" + hasNodesToUpdate() + "\n" + " updaterState=" + myUpdaterState + "\n" + " hasScheduledUpdates=" + hasScheduledUpdates() + "\n" + " isPostponedMode=" + getUpdater().isInPostponeMode() + "\n" + " nodeActions=" + myNodeActions.keySet() + "\n" + " nodeChildrenActions=" + myNodeChildrenActions.keySet() + "\n" + "isReleased=" + isReleased() + "\n" + " isReleaseRequested=" + isReleaseRequested() + "\n" + "isCancelProcessed=" + isCancelProcessed() + "\n" + " isCancelRequested=" + myCancelRequest + "\n" + " isResettingToReadyNow=" + myResettingToReadyNow + "\n" + "canInitiateNewActivity=" + canInitiateNewActivity() + "\n" + "batchIndicators=" + myBatchIndicators; } public boolean hasPendingWork() { return hasNodesToUpdate() || myUpdaterState != null && myUpdaterState.isProcessingNow() || hasScheduledUpdates() && !getUpdater().isInPostponeMode(); } public boolean isIdle() { return !isYeildingNow() && !isWorkerBusy() && !hasUpdatingChildrenNow() && !isLoadingInBackgroundNow(); } private void executeYieldingRequest(@NotNull Runnable runnable, @NotNull TreeUpdatePass pass) { try { try { myYieldingPasses.remove(pass); if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } runnable.run(); } finally { if (!isReleased()) { maybeYieldingFinished(); } } } catch (ProcessCanceledException e) { resetToReady(); } } private void maybeYieldingFinished() { if (myYieldingPasses.isEmpty()) { myYieldingNow = false; flushPendingNodeActions(); } } void maybeReady() { assertIsDispatchThread(); if (isReleased()) return; boolean ready = isReady(true); if (!ready) return; myRevalidatedObjects.clear(); setCancelRequested(false); myResettingToReadyNow.set(false); myInitialized.setDone(); if (canInitiateNewActivity()) { if (myUpdaterState != null && !myUpdaterState.isProcessingNow()) { UpdaterTreeState oldState = myUpdaterState; if (!myUpdaterState.restore(null)) { setUpdaterState(oldState); } if (!isReady(true)) return; } } setHoldSize(false); if (myTree.isShowing()) { if (getBuilder().isToEnsureSelectionOnFocusGained() && Registry.is("ide.tree.ensureSelectionOnFocusGained")) { TreeUtil.ensureSelection(myTree); } } if (myInitialized.isDone()) { if (isReleaseRequested() || isCancelProcessed()) { myBusyObject.onReady(this); } else { myBusyObject.onReady(); } } if (canInitiateNewActivity()) { TreePath[] selection = getTree().getSelectionPaths(); Rectangle visible = getTree().getVisibleRect(); if (selection != null) { for (TreePath each : selection) { Rectangle bounds = getTree().getPathBounds(each); if (bounds != null && (visible.contains(bounds) || visible.intersects(bounds))) { getTree().repaint(bounds); } } } } } private void flushPendingNodeActions() { final DefaultMutableTreeNode[] nodes = myPendingNodeActions.toArray(new DefaultMutableTreeNode[0]); myPendingNodeActions.clear(); for (DefaultMutableTreeNode each : nodes) { processNodeActionsIfReady(each); } final Runnable[] actions = myYieldingDoneRunnables.toArray(new Runnable[0]); for (Runnable each : actions) { if (!isYeildingNow()) { myYieldingDoneRunnables.remove(each); each.run(); } } maybeReady(); } protected void runOnYieldingDone(@NotNull Runnable onDone) { getBuilder().runOnYieldingDone(onDone); } protected void yieldToEDT(@NotNull Runnable runnable) { getBuilder().yieldToEDT(runnable); } @NotNull private MutualMap<Object, Integer> loadElementsFromStructure(final NodeDescriptor descriptor, @Nullable LoadedChildren preloadedChildren) { MutualMap<Object, Integer> elementToIndexMap = new MutualMap<>(true); final Object element = getElementFromDescriptor(descriptor); if (!isValid(element)) return elementToIndexMap; List<Object> children = preloadedChildren != null ? preloadedChildren.getElements() : Arrays.asList(getChildrenFor(element)); int index = 0; for (Object child : children) { if (!isValid(child)) continue; elementToIndexMap.put(child, index); index++; } return elementToIndexMap; } public static boolean isLoadingNode(final Object node) { return node instanceof LoadingNode; } @NotNull private AsyncResult<List<TreeNode>> collectNodesToInsert(final NodeDescriptor descriptor, @NotNull final MutualMap<Object, Integer> elementToIndexMap, final DefaultMutableTreeNode parent, final boolean addLoadingNode, @NotNull final LoadedChildren loadedChildren) { final AsyncResult<List<TreeNode>> result = new AsyncResult<>(); final List<TreeNode> nodesToInsert = new ArrayList<>(); Collection<Object> allElements = elementToIndexMap.getKeys(); ActionCallback processingDone = allElements.isEmpty() ? ActionCallback.DONE : new ActionCallback(allElements.size()); for (final Object child : allElements) { Integer index = elementToIndexMap.getValue(child); boolean needToUpdate = false; NodeDescriptor loadedDesc = loadedChildren.getDescriptor(child); final NodeDescriptor childDescr; if (!isValid(loadedDesc, descriptor)) { childDescr = getTreeStructure().createDescriptor(child, descriptor); needToUpdate = true; } else { childDescr = loadedDesc; } if (index == null) { index = Integer.MAX_VALUE; needToUpdate = true; } childDescr.setIndex(index.intValue()); final ActionCallback update = new ActionCallback(); if (needToUpdate) { update(childDescr, false) .onSuccess(changes -> { loadedChildren.putDescriptor(child, childDescr, changes); update.setDone(); }); } else { update.setDone(); } update.doWhenDone(new TreeRunnable("AbstractTreeUi.collectNodesToInsert: on done update") { @Override public void perform() { Object element = getElementFromDescriptor(childDescr); if (!isNodeNull(element)) { DefaultMutableTreeNode node = getNodeForElement(element, false); if (node == null || node.getParent() != parent) { final DefaultMutableTreeNode childNode = createChildNode(childDescr); if (addLoadingNode || getBuilder().isAlwaysShowPlus(childDescr)) { insertLoadingNode(childNode, true); } else { addToUnbuilt(childNode); } nodesToInsert.add(childNode); createMapping(element, childNode); } } processingDone.setDone(); } }); } processingDone.doWhenDone(new TreeRunnable("AbstractTreeUi.collectNodesToInsert: on done processing") { @Override public void perform() { result.setDone(nodesToInsert); } }); return result; } @NotNull protected DefaultMutableTreeNode createChildNode(final NodeDescriptor descriptor) { return new ElementNode(this, descriptor); } protected boolean canYield() { return myCanYield && myYieldingUpdate.asBoolean(); } private long getClearOnHideDelay() { return myClearOnHideDelay; } @NotNull public ActionCallback getInitialized() { return myInitialized; } public ActionCallback getReady(@NotNull Object requestor) { return myBusyObject.getReady(requestor); } private ActionCallback _getReady() { return getReady(this); } private void addToUpdatingChildren(@NotNull DefaultMutableTreeNode node) { synchronized (myUpdatingChildren) { myUpdatingChildren.add(node); } } private void removeFromUpdatingChildren(@NotNull DefaultMutableTreeNode node) { synchronized (myUpdatingChildren) { myUpdatingChildren.remove(node); } } boolean isUpdatingChildrenNow(DefaultMutableTreeNode node) { synchronized (myUpdatingChildren) { return myUpdatingChildren.contains(node); } } boolean isParentUpdatingChildrenNow(@NotNull DefaultMutableTreeNode node) { synchronized (myUpdatingChildren) { DefaultMutableTreeNode eachParent = (DefaultMutableTreeNode)node.getParent(); while (eachParent != null) { if (myUpdatingChildren.contains(eachParent)) return true; eachParent = (DefaultMutableTreeNode)eachParent.getParent(); } return false; } } private boolean hasUpdatingChildrenNow() { synchronized (myUpdatingChildren) { return !myUpdatingChildren.isEmpty(); } } @NotNull Map<Object, List<NodeAction>> getNodeActions() { return myNodeActions; } @NotNull List<Object> getLoadedChildrenFor(@NotNull Object element) { List<Object> result = new ArrayList<>(); DefaultMutableTreeNode node = getNodeForElement(element, false); if (node != null) { for (int i = 0; i < node.getChildCount(); i++) { TreeNode each = node.getChildAt(i); if (isLoadingNode(each)) continue; result.add(getElementFor(each)); } } return result; } boolean hasNodesToUpdate() { return getUpdater().hasNodesToUpdate(); } @NotNull public List<Object> getExpandedElements() { final List<Object> result = new ArrayList<>(); if (isReleased()) return result; final Enumeration<TreePath> enumeration = myTree.getExpandedDescendants(getPathFor(getRootNode())); if (enumeration != null) { while (enumeration.hasMoreElements()) { TreePath each = enumeration.nextElement(); Object eachElement = getElementFor(each.getLastPathComponent()); if (eachElement != null) { result.add(eachElement); } } } return result; } @NotNull public ActionCallback cancelUpdate() { if (isReleased()) return ActionCallback.REJECTED; setCancelRequested(true); final ActionCallback done = new ActionCallback(); invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.cancelUpdate") { @Override public void perform() { if (isReleased()) { done.setRejected(); return; } if (myResettingToReadyNow.get()) { _getReady().notify(done); } else if (isReady()) { resetToReadyNow(); done.setDone(); } else { if (isIdle() && hasPendingWork()) { resetToReadyNow(); done.setDone(); } else { _getReady().notify(done); } } maybeReady(); } }); if (isEdt() || isPassthroughMode()) { maybeReady(); } return done; } private void setCancelRequested(boolean requested) { try (LockToken ignored = isUnitTestingMode() ? acquireLock() : attemptLock()) { myCancelRequest.set(requested); } catch (InterruptedException ignored) { } } @Nullable private LockToken attemptLock() throws InterruptedException { return LockToken.attemptLock(myStateLock, Registry.intValue("ide.tree.uiLockAttempt")); } @NotNull private LockToken acquireLock() { return LockToken.acquireLock(myStateLock); } @NotNull public ActionCallback batch(@NotNull final Progressive progressive) { assertIsDispatchThread(); EmptyProgressIndicator indicator = new EmptyProgressIndicator(); final ActionCallback callback = new ActionCallback(); myBatchIndicators.put(progressive, indicator); myBatchCallbacks.put(progressive, callback); try { progressive.run(indicator); } catch (ProcessCanceledException e) { resetToReadyNow().doWhenProcessed(new TreeRunnable("AbstractTreeUi.batch: catch") { @Override public void perform() { callback.setRejected(); } }); return callback; } finally { if (isReleased()) return ActionCallback.REJECTED; _getReady().doWhenDone(new TreeRunnable("AbstractTreeUi.batch: finally") { @Override public void perform() { if (myBatchIndicators.containsKey(progressive)) { ProgressIndicator indicator = myBatchIndicators.remove(progressive); myBatchCallbacks.remove(progressive); if (indicator.isCanceled()) { callback.setRejected(); } else { callback.setDone(); } } else { callback.setRejected(); } } }); maybeReady(); } return callback; } boolean isCancelProcessed() { return myCancelRequest.get() || myResettingToReadyNow.get(); } boolean isToPaintSelection() { return isReady(true) || !mySelectionIsAdjusted; } boolean isReleaseRequested() { return myReleaseRequested; } public void executeUserRunnable(@NotNull Runnable runnable) { try { myUserRunnables.add(runnable); runnable.run(); } finally { myUserRunnables.remove(runnable); } } static class ElementNode extends DefaultMutableTreeNode { Set<Object> myElements = new HashSet<>(); AbstractTreeUi myUi; ElementNode(AbstractTreeUi ui, NodeDescriptor descriptor) { super(descriptor); myUi = ui; } @Override public void insert(final MutableTreeNode newChild, final int childIndex) { super.insert(newChild, childIndex); final Object element = myUi.getElementFor(newChild); if (element != null) { myElements.add(element); } } @Override public void remove(final int childIndex) { final TreeNode node = getChildAt(childIndex); super.remove(childIndex); final Object element = myUi.getElementFor(node); if (element != null) { myElements.remove(element); } } boolean isValidChild(Object childElement) { return myElements.contains(childElement); } @Override public String toString() { return String.valueOf(getUserObject()); } } private boolean isUpdatingParent(DefaultMutableTreeNode kid) { return getUpdatingParent(kid) != null; } @Nullable private DefaultMutableTreeNode getUpdatingParent(DefaultMutableTreeNode kid) { DefaultMutableTreeNode eachParent = kid; while (eachParent != null) { if (isUpdatingChildrenNow(eachParent)) return eachParent; eachParent = (DefaultMutableTreeNode)eachParent.getParent(); } return null; } private boolean isLoadedInBackground(Object element) { return getLoadedInBackground(element) != null; } private UpdateInfo getLoadedInBackground(Object element) { synchronized (myLoadedInBackground) { return isNodeNull(element) ? null : myLoadedInBackground.get(element); } } private void addToLoadedInBackground(Object element, UpdateInfo info) { if (isNodeNull(element)) return; synchronized (myLoadedInBackground) { warnMap("put into myLoadedInBackground: ", myLoadedInBackground); myLoadedInBackground.put(element, info); } } private void removeFromLoadedInBackground(final Object element) { if (isNodeNull(element)) return; synchronized (myLoadedInBackground) { warnMap("remove from myLoadedInBackground: ", myLoadedInBackground); myLoadedInBackground.remove(element); } } private boolean isLoadingInBackgroundNow() { synchronized (myLoadedInBackground) { return !myLoadedInBackground.isEmpty(); } } private void queueBackgroundUpdate(@NotNull final UpdateInfo updateInfo, @NotNull final DefaultMutableTreeNode node) { assertIsDispatchThread(); final Object oldElementFromDescriptor = getElementFromDescriptor(updateInfo.getDescriptor()); if (isNodeNull(oldElementFromDescriptor)) return; UpdateInfo loaded = getLoadedInBackground(oldElementFromDescriptor); if (loaded != null) { loaded.apply(updateInfo); return; } addToLoadedInBackground(oldElementFromDescriptor, updateInfo); maybeSetBusyAndScheduleWaiterForReady(true, oldElementFromDescriptor); if (!isNodeBeingBuilt(node)) { LoadingNode loadingNode = new LoadingNode(getLoadingNodeText()); myTreeModel.insertNodeInto(loadingNode, node, node.getChildCount()); } removeFromUnbuilt(node); final Ref<LoadedChildren> children = new Ref<>(); final Ref<Object> elementFromDescriptor = new Ref<>(); final DefaultMutableTreeNode[] nodeToProcessActions = new DefaultMutableTreeNode[1]; final TreeConsumer<Void> finalizeRunnable = new TreeConsumer<>("AbstractTreeUi.queueBackgroundUpdate: finalize") { @Override public void perform() { invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.queueBackgroundUpdate: finalize later") { @Override public void perform() { if (isReleased()) return; removeLoading(node, false); removeFromLoadedInBackground(elementFromDescriptor.get()); removeFromLoadedInBackground(oldElementFromDescriptor); if (nodeToProcessActions[0] != null) { processNodeActionsIfReady(nodeToProcessActions[0]); } } }); } }; Runnable buildRunnable = new TreeRunnable("AbstractTreeUi.queueBackgroundUpdate: build") { @Override public void perform() { if (updateInfo.getPass().isExpired()) { finalizeRunnable.run(); return; } if (!updateInfo.isDescriptorIsUpToDate()) { update(updateInfo.getDescriptor(), true); } if (!updateInfo.isUpdateChildren()) { nodeToProcessActions[0] = node; return; } Object element = getElementFromDescriptor(updateInfo.getDescriptor()); if (element == null) { removeFromLoadedInBackground(oldElementFromDescriptor); finalizeRunnable.run(); return; } elementFromDescriptor.set(element); Object[] loadedElements = getChildrenFor(element); final LoadedChildren loaded = new LoadedChildren(loadedElements); for (final Object each : loadedElements) { NodeDescriptor<?> existingDesc = getDescriptorFrom(getNodeForElement(each, true)); NodeDescriptor<?> eachChildDescriptor = isValid(existingDesc, updateInfo.getDescriptor()) ? existingDesc : getTreeStructure().createDescriptor(each, updateInfo.getDescriptor()); execute(new TreeRunnable("AbstractTreeUi.queueBackgroundUpdate") { @Override public void perform() { try { loaded.putDescriptor(each, eachChildDescriptor, update(eachChildDescriptor, true).blockingGet(0)); } catch (TimeoutException | ExecutionException e) { LOG.error(e); } } }); } children.set(loaded); } @NotNull @NonNls @Override public String toString() { return "runnable=" + oldElementFromDescriptor; } }; Runnable updateRunnable = new TreeRunnable("AbstractTreeUi.queueBackgroundUpdate: update") { @Override public void perform() { if (updateInfo.getPass().isExpired()) { finalizeRunnable.run(); return; } if (children.get() == null) { finalizeRunnable.run(); return; } if (isRerunNeeded(updateInfo.getPass())) { removeFromLoadedInBackground(elementFromDescriptor.get()); getUpdater().requeue(updateInfo.getPass()); return; } removeFromLoadedInBackground(elementFromDescriptor.get()); if (myUnbuiltNodes.contains(node)) { Pair<Boolean, LoadedChildren> unbuilt = processUnbuilt(node, updateInfo.getDescriptor(), updateInfo.getPass(), isExpanded(node, updateInfo.isWasExpanded()), children.get()); if (unbuilt.getFirst()) { nodeToProcessActions[0] = node; return; } } ActionCallback callback = updateNodeChildren(node, updateInfo.getPass(), children.get(), true, updateInfo.isCanSmartExpand(), updateInfo.isForceUpdate(), true, true); callback.doWhenDone(new TreeRunnable("AbstractTreeUi.queueBackgroundUpdate: on done updateNodeChildren") { @Override public void perform() { if (isRerunNeeded(updateInfo.getPass())) { getUpdater().requeue(updateInfo.getPass()); return; } Object element = elementFromDescriptor.get(); if (element != null) { removeLoading(node, false); nodeToProcessActions[0] = node; } } }); } }; queueToBackground(buildRunnable, updateRunnable) .onSuccess(finalizeRunnable) .onError(new TreeConsumer<>("AbstractTreeUi.queueBackgroundUpdate: on rejected") { @Override public void perform() { updateInfo.getPass().expire(); } }); } private boolean isExpanded(@NotNull DefaultMutableTreeNode node, boolean isExpanded) { return isExpanded || myTree.isExpanded(getPathFor(node)); } private void removeLoading(@NotNull DefaultMutableTreeNode parent, boolean forced) { if (!forced && myUnbuiltNodes.contains(parent) && !myCancelledBuild.containsKey(parent)) { return; } boolean reallyRemoved = false; for (int i = 0; i < parent.getChildCount(); i++) { TreeNode child = parent.getChildAt(i); if (removeIfLoading(child)) { reallyRemoved = true; i--; } } maybeReady(); if (reallyRemoved) { nodeStructureChanged(parent); } } private void processNodeActionsIfReady(@NotNull final DefaultMutableTreeNode node) { assertIsDispatchThread(); if (isNodeBeingBuilt(node)) return; NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; if (isYeildingNow()) { myPendingNodeActions.add(node); return; } final Object element = getElementFromDescriptor(descriptor); boolean childrenReady = !isLoadedInBackground(element) && !isUpdatingChildrenNow(node); processActions(node, element, myNodeActions, childrenReady ? myNodeChildrenActions : null); if (childrenReady) { processActions(node, element, myNodeChildrenActions, null); } warnMap("myNodeActions: processNodeActionsIfReady: ", myNodeActions); warnMap("myNodeChildrenActions: processNodeActionsIfReady: ", myNodeChildrenActions); if (!isUpdatingParent(node) && !isWorkerBusy()) { final UpdaterTreeState state = myUpdaterState; if (myNodeActions.isEmpty() && state != null && !state.isProcessingNow()) { if (canInitiateNewActivity()) { if (!state.restore(childrenReady ? node : null)) { setUpdaterState(state); } } } } maybeReady(); } private static void processActions(@NotNull DefaultMutableTreeNode node, Object element, @NotNull final Map<Object, List<NodeAction>> nodeActions, @Nullable final Map<Object, List<NodeAction>> secondaryNodeAction) { final List<NodeAction> actions = nodeActions.get(element); if (actions != null) { nodeActions.remove(element); List<NodeAction> secondary = secondaryNodeAction != null ? secondaryNodeAction.get(element) : null; for (NodeAction each : actions) { if (secondary != null) { secondary.remove(each); } each.onReady(node); } } } private boolean canSmartExpand(DefaultMutableTreeNode node, boolean canSmartExpand) { if (!canInitiateNewActivity()) return false; if (!getBuilder().isSmartExpand()) return false; boolean smartExpand = canSmartExpand && !myNotForSmartExpand.contains(node); Object element = getElementFor(node); return smartExpand && element != null && validateAutoExpand(true, element); } private void processSmartExpand(@NotNull final DefaultMutableTreeNode node, final boolean canSmartExpand, boolean forced) { if (!canInitiateNewActivity()) return; if (!getBuilder().isSmartExpand()) return; boolean can = canSmartExpand(node, canSmartExpand); if (!can && !forced) return; if (isNodeBeingBuilt(node) && !forced) { addNodeAction(getElementFor(node), true, node1 -> processSmartExpand(node1, canSmartExpand, true)); } else { TreeNode child = getChildForSmartExpand(node); if (child != null) { final TreePath childPath = new TreePath(node.getPath()).pathByAddingChild(child); processInnerChange(new TreeRunnable("AbstractTreeUi.processSmartExpand") { @Override public void perform() { myTree.expandPath(childPath); } }); } } } @Nullable private static TreeNode getChildForSmartExpand(@NotNull DefaultMutableTreeNode node) { int realChildCount = 0; TreeNode nodeToExpand = null; for (int i = 0; i < node.getChildCount(); i++) { TreeNode eachChild = node.getChildAt(i); if (!isLoadingNode(eachChild)) { realChildCount++; if (nodeToExpand == null) { nodeToExpand = eachChild; } } if (realChildCount > 1) { nodeToExpand = null; break; } } return nodeToExpand; } public static boolean isLoadingChildrenFor(final Object nodeObject) { if (!(nodeObject instanceof DefaultMutableTreeNode)) return false; DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodeObject; int loadingNodes = 0; for (int i = 0; i < Math.min(node.getChildCount(), 2); i++) { TreeNode child = node.getChildAt(i); if (isLoadingNode(child)) { loadingNodes++; } } return loadingNodes > 0 && loadingNodes == node.getChildCount(); } boolean isParentLoadingInBackground(@NotNull Object nodeObject) { return getParentLoadingInBackground(nodeObject) != null; } @Nullable private DefaultMutableTreeNode getParentLoadingInBackground(@NotNull Object nodeObject) { if (!(nodeObject instanceof DefaultMutableTreeNode)) return null; DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodeObject; TreeNode eachParent = node.getParent(); while (eachParent != null) { eachParent = eachParent.getParent(); if (eachParent instanceof DefaultMutableTreeNode) { final Object eachElement = getElementFor(eachParent); if (isLoadedInBackground(eachElement)) return (DefaultMutableTreeNode)eachParent; } } return null; } private static @Nls String getLoadingNodeText() { return IdeBundle.message("progress.searching"); } @NotNull private Promise<?> processExistingNode(@NotNull final DefaultMutableTreeNode childNode, final NodeDescriptor childDescriptor, @NotNull final DefaultMutableTreeNode parentNode, @NotNull final MutualMap<Object, Integer> elementToIndexMap, @NotNull final TreeUpdatePass pass, final boolean canSmartExpand, final boolean forceUpdate, @Nullable LoadedChildren parentPreloadedChildren) { if (pass.isExpired()) { return Promises.<Void>rejectedPromise(); } if (childDescriptor == null) { pass.expire(); return Promises.<Void>rejectedPromise(); } final Object oldElement = getElementFromDescriptor(childDescriptor); if (isNodeNull(oldElement)) { // if a tree node with removed element was not properly removed from a tree model // we must not ignore this situation and should remove a wrong node removeNodeFromParent(childNode, true); doUpdateNode(parentNode); return Promises.<Void>resolvedPromise(); } Promise<Boolean> update; if (parentPreloadedChildren != null && parentPreloadedChildren.getDescriptor(oldElement) == childDescriptor) { update = Promises.resolvedPromise(parentPreloadedChildren.isUpdated(oldElement)); } else { update = update(childDescriptor, false); } final AsyncPromise<Void> result = new AsyncPromise<>(); final Ref<NodeDescriptor> childDesc = new Ref<>(childDescriptor); update .onSuccess(isChanged -> { final AtomicBoolean changes = new AtomicBoolean(isChanged); final AtomicBoolean forceRemapping = new AtomicBoolean(); final Ref<Object> newElement = new Ref<>(getElementFromDescriptor(childDesc.get())); final Integer index = newElement.get() == null ? null : elementToIndexMap.getValue(getElementFromDescriptor(childDesc.get())); Promise<Boolean> promise; if (index == null) { promise = Promises.resolvedPromise(false); } else { final Object elementFromMap = elementToIndexMap.getKey(index); if (elementFromMap != newElement.get() && elementFromMap.equals(newElement.get())) { if (isInStructure(elementFromMap) && isInStructure(newElement.get())) { final AsyncPromise<Boolean> updateIndexDone = new AsyncPromise<>(); promise = updateIndexDone; NodeDescriptor parentDescriptor = getDescriptorFrom(parentNode); if (parentDescriptor != null) { childDesc.set(getTreeStructure().createDescriptor(elementFromMap, parentDescriptor)); NodeDescriptor oldDesc = getDescriptorFrom(childNode); if (isValid(oldDesc)) { childDesc.get().applyFrom(oldDesc); } childNode.setUserObject(childDesc.get()); newElement.set(elementFromMap); forceRemapping.set(true); update(childDesc.get(), false) .onSuccess(isChanged1 -> { changes.set(isChanged1); updateIndexDone.setResult(isChanged1); }); } // todo why we don't process promise here? } else { promise = Promises.resolvedPromise(changes.get()); } } else { promise = Promises.resolvedPromise(changes.get()); } promise .onSuccess(new TreeConsumer<>("AbstractTreeUi.processExistingNode: on done index updating after update") { @Override public void perform() { if (childDesc.get().getIndex() != index.intValue()) { changes.set(true); } childDesc.get().setIndex(index.intValue()); } }); } promise .onSuccess(new TreeConsumer<>("AbstractTreeUi.processExistingNode: on done index updating") { @Override public void perform() { if (!oldElement.equals(newElement.get()) || forceRemapping.get()) { removeMapping(oldElement, childNode, newElement.get()); Object newE = newElement.get(); if (!isNodeNull(newE)) { createMapping(newE, childNode); } NodeDescriptor parentDescriptor = getDescriptorFrom(parentNode); if (parentDescriptor != null) { parentDescriptor.setChildrenSortingStamp(-1); } } if (index == null) { int selectedIndex = -1; if (TreeBuilderUtil.isNodeOrChildSelected(myTree, childNode)) { selectedIndex = parentNode.getIndex(childNode); } if (childNode.getParent() instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode parent = (DefaultMutableTreeNode)childNode.getParent(); if (myTree.isExpanded(new TreePath(parent.getPath()))) { if (parent.getChildCount() == 1 && parent.getChildAt(0) == childNode) { insertLoadingNode(parent, false); } } } Object disposedElement = getElementFor(childNode); removeNodeFromParent(childNode, selectedIndex >= 0); disposeNode(childNode); adjustSelectionOnChildRemove(parentNode, selectedIndex, disposedElement); result.setResult(null); } else { elementToIndexMap.remove(getElementFromDescriptor(childDesc.get())); updateNodeChildren(childNode, pass, null, false, canSmartExpand, forceUpdate, true, true) .doWhenDone(() -> result.setResult(null)); } } }); }); return result; } private void adjustSelectionOnChildRemove(@NotNull DefaultMutableTreeNode parentNode, int selectedIndex, Object disposedElement) { if (selectedIndex >= 0 && !getSelectedElements().isEmpty()) return; DefaultMutableTreeNode node = disposedElement == null ? null : getNodeForElement(disposedElement, false); if (node != null && isValidForSelectionAdjusting(node)) { Object newElement = getElementFor(node); addSelectionPath(getPathFor(node), true, getExpiredElementCondition(newElement), disposedElement); return; } if (selectedIndex >= 0) { if (parentNode.getChildCount() > 0) { if (parentNode.getChildCount() > selectedIndex) { TreeNode newChildNode = parentNode.getChildAt(selectedIndex); if (isValidForSelectionAdjusting(newChildNode)) { addSelectionPath(new TreePath(myTreeModel.getPathToRoot(newChildNode)), true, getExpiredElementCondition(disposedElement), disposedElement); } } else { TreeNode newChild = parentNode.getChildAt(parentNode.getChildCount() - 1); if (isValidForSelectionAdjusting(newChild)) { addSelectionPath(new TreePath(myTreeModel.getPathToRoot(newChild)), true, getExpiredElementCondition(disposedElement), disposedElement); } } } else { addSelectionPath(new TreePath(myTreeModel.getPathToRoot(parentNode)), true, getExpiredElementCondition(disposedElement), disposedElement); } } } private boolean isValidForSelectionAdjusting(@NotNull TreeNode node) { if (!myTree.isRootVisible() && getRootNode() == node) return false; if (isLoadingNode(node)) return true; final Object elementInTree = getElementFor(node); if (elementInTree == null) return false; final TreeNode parentNode = node.getParent(); final Object parentElementInTree = getElementFor(parentNode); if (parentElementInTree == null) return false; final Object parentElement = getTreeStructure().getParentElement(elementInTree); return parentElementInTree.equals(parentElement); } @NotNull private Condition getExpiredElementCondition(final Object element) { return o -> isInStructure(element); } private void addSelectionPath(@NotNull final TreePath path, final boolean isAdjustedSelection, final Condition isExpiredAdjustment, @Nullable final Object adjustmentCause) { processInnerChange(new TreeRunnable("AbstractTreeUi.addSelectionPath") { @Override public void perform() { TreePath toSelect = null; if (isLoadingNode(path.getLastPathComponent())) { final TreePath parentPath = path.getParentPath(); if (parentPath != null && isValidForSelectionAdjusting((TreeNode)parentPath.getLastPathComponent())) { toSelect = parentPath; } } else { toSelect = path; } if (toSelect != null) { mySelectionIsAdjusted = isAdjustedSelection; myTree.addSelectionPath(toSelect); if (isAdjustedSelection && myUpdaterState != null) { final Object toSelectElement = getElementFor(toSelect.getLastPathComponent()); myUpdaterState.addAdjustedSelection(toSelectElement, isExpiredAdjustment, adjustmentCause); } } } }); } @NotNull private static TreePath getPathFor(@NotNull TreeNode node) { if (node instanceof DefaultMutableTreeNode) { return new TreePath(((DefaultMutableTreeNode)node).getPath()); } else { List<TreeNode> nodes = new ArrayList<>(); TreeNode eachParent = node; while (eachParent != null) { nodes.add(eachParent); eachParent = eachParent.getParent(); } return new TreePath(ArrayUtil.toObjectArray(nodes)); } } private void removeNodeFromParent(@NotNull final MutableTreeNode node, final boolean willAdjustSelection) { processInnerChange(new TreeRunnable("AbstractTreeUi.removeNodeFromParent") { @Override public void perform() { if (willAdjustSelection) { final TreePath path = getPathFor(node); if (myTree.isPathSelected(path)) { myTree.removeSelectionPath(path); } } if (node.getParent() != null) { myTreeModel.removeNodeFromParent(node); } } }); } private void expandPath(@NotNull final TreePath path, final boolean canSmartExpand) { processInnerChange(new TreeRunnable("AbstractTreeUi.expandPath") { @Override public void perform() { if (path.getLastPathComponent() instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (node.getChildCount() > 0 && !myTree.isExpanded(path)) { if (!canSmartExpand) { myNotForSmartExpand.add(node); } try { myRequestedExpand = path; myTree.expandPath(path); processSmartExpand(node, canSmartExpand, false); } finally { myNotForSmartExpand.remove(node); myRequestedExpand = null; } } else { processNodeActionsIfReady(node); } } } }); } private void processInnerChange(Runnable runnable) { if (myUpdaterState == null) { setUpdaterState(new UpdaterTreeState(this)); } myUpdaterState.process(runnable); } private boolean isInnerChange() { return myUpdaterState != null && myUpdaterState.isProcessingNow() && myUserRunnables.isEmpty(); } private void makeLoadingOrLeafIfNoChildren(@NotNull final DefaultMutableTreeNode node) { TreePath path = getPathFor(node); insertLoadingNode(node, true); final NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; descriptor.setChildrenSortingStamp(-1); if (getBuilder().isAlwaysShowPlus(descriptor)) return; TreePath parentPath = path.getParentPath(); if (myTree.isVisible(path) || parentPath != null && myTree.isExpanded(parentPath)) { if (myTree.isExpanded(path)) { addSubtreeToUpdate(node); } else { insertLoadingNode(node, false); } } } /** * Indicates whether the given {@code descriptor} is valid * and its parent is equal to the specified {@code parent}. * * @param descriptor a descriptor to test * @param parent an expected parent for the testing descriptor * @return {@code true} if the specified descriptor is valid */ private boolean isValid(NodeDescriptor descriptor, NodeDescriptor parent) { if (descriptor == null) return false; if (parent != null && parent != descriptor.getParentDescriptor()) return false; return isValid(getElementFromDescriptor(descriptor)); } private boolean isValid(@Nullable NodeDescriptor descriptor) { return descriptor != null && isValid(getElementFromDescriptor(descriptor)); } private boolean isValid(Object element) { if (isNodeNull(element)) return false; if (element instanceof ValidateableNode) { if (!((ValidateableNode)element).isValid()) return false; } return getBuilder().validateNode(element); } private void insertLoadingNode(final DefaultMutableTreeNode node, boolean addToUnbuilt) { if (!isLoadingChildrenFor(node)) { myTreeModel.insertNodeInto(new LoadingNode(), node, 0); } if (addToUnbuilt) { addToUnbuilt(node); } } @NotNull private Promise<Void> queueToBackground(@NotNull final Runnable bgBuildAction, @Nullable final Runnable edtPostRunnable) { if (!canInitiateNewActivity()) return Promises.rejectedPromise(); final AsyncPromise<Void> result = new AsyncPromise<>(); final AtomicReference<ProcessCanceledException> fail = new AtomicReference<>(); final Runnable finalizer = new TreeRunnable("AbstractTreeUi.queueToBackground: finalizer") { @Override public void perform() { ProcessCanceledException exception = fail.get(); if (exception == null) { result.setResult(null); } else { result.setError(exception); } } }; registerWorkerTask(bgBuildAction); final Runnable pooledThreadWithProgressRunnable = new TreeRunnable("AbstractTreeUi.queueToBackground: progress") { @Override public void perform() { try { final AbstractTreeBuilder builder = getBuilder(); if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } builder.runBackgroundLoading(new TreeRunnable("AbstractTreeUi.queueToBackground: background") { @Override public void perform() { assertNotDispatchThread(); try { if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } execute(bgBuildAction); if (edtPostRunnable != null) { builder.updateAfterLoadedInBackground(new TreeRunnable("AbstractTreeUi.queueToBackground: update after") { @Override public void perform() { try { assertIsDispatchThread(); if (!canInitiateNewActivity()) { throw new ProcessCanceledException(); } execute(edtPostRunnable); } catch (ProcessCanceledException e) { fail.set(e); cancelUpdate(); } finally { unregisterWorkerTask(bgBuildAction, finalizer); } } }); } else { unregisterWorkerTask(bgBuildAction, finalizer); } } catch (ProcessCanceledException e) { fail.set(e); unregisterWorkerTask(bgBuildAction, finalizer); cancelUpdate(); } catch (Throwable t) { unregisterWorkerTask(bgBuildAction, finalizer); throw new RuntimeException(t); } } }); } catch (ProcessCanceledException e) { unregisterWorkerTask(bgBuildAction, finalizer); cancelUpdate(); } } }; Runnable pooledThreadRunnable = new TreeRunnable("AbstractTreeUi.queueToBackground") { @Override public void perform() { try { if (myProgress != null && ProgressManager.getGlobalProgressIndicator() != myProgress) { ProgressManager.getInstance().runProcess(pooledThreadWithProgressRunnable, myProgress); } else { execute(pooledThreadWithProgressRunnable); } } catch (ProcessCanceledException e) { fail.set(e); unregisterWorkerTask(bgBuildAction, finalizer); cancelUpdate(); } } }; if (isPassthroughMode()) { execute(pooledThreadRunnable); } else { myWorker.addFirst(pooledThreadRunnable); } return result; } private void registerWorkerTask(@NotNull Runnable runnable) { synchronized (myActiveWorkerTasks) { myActiveWorkerTasks.add(runnable); } } private void unregisterWorkerTask(@NotNull Runnable runnable, @Nullable Runnable finalizeRunnable) { boolean wasRemoved; synchronized (myActiveWorkerTasks) { wasRemoved = myActiveWorkerTasks.remove(runnable); } if (wasRemoved && finalizeRunnable != null) { finalizeRunnable.run(); } invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.unregisterWorkerTask") { @Override public void perform() { maybeReady(); } }); } private boolean isWorkerBusy() { synchronized (myActiveWorkerTasks) { return !myActiveWorkerTasks.isEmpty(); } } private void clearWorkerTasks() { synchronized (myActiveWorkerTasks) { myActiveWorkerTasks.clear(); } } private void updateNodeImageAndPosition(@NotNull final DefaultMutableTreeNode node) { NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; if (getElementFromDescriptor(descriptor) == null) return; nodeChanged(node); } private void nodeChanged(final DefaultMutableTreeNode node) { invokeLaterIfNeeded(true, new TreeRunnable("AbstractTreeUi.nodeChanged") { @Override public void perform() { myTreeModel.nodeChanged(node); } }); } private void nodeStructureChanged(final DefaultMutableTreeNode node) { invokeLaterIfNeeded(true, new TreeRunnable("AbstractTreeUi.nodeStructureChanged") { @Override public void perform() { myTreeModel.nodeStructureChanged(node); } }); } public DefaultTreeModel getTreeModel() { return myTreeModel; } private void insertNodesInto(@NotNull final List<? extends TreeNode> toInsert, @NotNull final DefaultMutableTreeNode parentNode) { sortChildren(parentNode, toInsert, false, true); final List<TreeNode> all = new ArrayList<>(toInsert.size() + parentNode.getChildCount()); all.addAll(toInsert); all.addAll(TreeUtil.listChildren(parentNode)); if (!toInsert.isEmpty()) { sortChildren(parentNode, all, true, true); int[] newNodeIndices = new int[toInsert.size()]; int eachNewNodeIndex = 0; TreeMap<Integer, TreeNode> insertSet = new TreeMap<>(); for (int i = 0; i < toInsert.size(); i++) { TreeNode eachNewNode = toInsert.get(i); while (all.get(eachNewNodeIndex) != eachNewNode) { eachNewNodeIndex++; } newNodeIndices[i] = eachNewNodeIndex; insertSet.put(eachNewNodeIndex, eachNewNode); } for (Map.Entry<Integer, TreeNode> entry : insertSet.entrySet()) { TreeNode eachNode = entry.getValue(); Integer index = entry.getKey(); parentNode.insert((MutableTreeNode)eachNode, index); } myTreeModel.nodesWereInserted(parentNode, newNodeIndices); } else { List<TreeNode> before = new ArrayList<>(all); sortChildren(parentNode, all, true, false); if (!before.equals(all)) { processInnerChange(new TreeRunnable("AbstractTreeUi.insertNodesInto") { @Override public void perform() { Enumeration<TreePath> expanded = getTree().getExpandedDescendants(getPathFor(parentNode)); TreePath[] selected = getTree().getSelectionModel().getSelectionPaths(); parentNode.removeAllChildren(); for (TreeNode each : all) { parentNode.add((MutableTreeNode)each); } nodeStructureChanged(parentNode); if (expanded != null) { while (expanded.hasMoreElements()) { expandSilently(expanded.nextElement()); } } if (selected != null) { for (TreePath each : selected) { if (!getTree().getSelectionModel().isPathSelected(each)) { addSelectionSilently(each); } } } } }); } } } private void sortChildren(@NotNull DefaultMutableTreeNode node, @NotNull List<? extends TreeNode> children, boolean updateStamp, boolean forceSort) { NodeDescriptor descriptor = getDescriptorFrom(node); assert descriptor != null; if (descriptor.getChildrenSortingStamp() >= getComparatorStamp() && !forceSort) return; if (!children.isEmpty()) { try { getBuilder().sortChildren(myNodeComparator, node, children); } catch (IllegalArgumentException exception) { StringBuilder sb = new StringBuilder("cannot sort children in ").append(toString()); children.forEach(child -> sb.append('\n').append(child)); throw new IllegalArgumentException(sb.toString(), exception); } } if (updateStamp) { descriptor.setChildrenSortingStamp(getComparatorStamp()); } } private void disposeNode(@NotNull DefaultMutableTreeNode node) { TreeNode parent = node.getParent(); if (parent instanceof DefaultMutableTreeNode) { addToUnbuilt((DefaultMutableTreeNode)parent); } if (node.getChildCount() > 0) { for (DefaultMutableTreeNode _node = (DefaultMutableTreeNode)node.getFirstChild(); _node != null; _node = _node.getNextSibling()) { disposeNode(_node); } } removeFromUpdatingChildren(node); removeFromUnbuilt(node); removeFromCancelled(node); if (isLoadingNode(node)) return; NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; final Object element = getElementFromDescriptor(descriptor); if (!isNodeNull(element)) { removeMapping(element, node, null); } myAutoExpandRoots.remove(element); node.setUserObject(null); node.removeAllChildren(); } public boolean addSubtreeToUpdate(@NotNull final DefaultMutableTreeNode root) { return addSubtreeToUpdate(root, true); } public boolean addSubtreeToUpdate(@NotNull final DefaultMutableTreeNode root, boolean updateStructure) { return addSubtreeToUpdate(root, null, updateStructure); } public boolean addSubtreeToUpdate(@NotNull final DefaultMutableTreeNode root, final Runnable runAfterUpdate) { return addSubtreeToUpdate(root, runAfterUpdate, true); } public boolean addSubtreeToUpdate(@NotNull final DefaultMutableTreeNode root, @Nullable final Runnable runAfterUpdate, final boolean updateStructure) { final Object element = getElementFor(root); final boolean alwaysLeaf = element != null && getTreeStructure().isAlwaysLeaf(element); final TreeUpdatePass updatePass; if (alwaysLeaf) { removeFromUnbuilt(root); removeLoading(root, true); updatePass = new TreeUpdatePass(root).setUpdateChildren(false); } else { updatePass = new TreeUpdatePass(root).setUpdateStructure(updateStructure).setUpdateStamp(-1); } final AbstractTreeUpdater updater = getUpdater(); updater.runAfterUpdate(runAfterUpdate); updater.addSubtreeToUpdate(updatePass); return !alwaysLeaf; } boolean wasRootNodeInitialized() { return myRootNodeWasQueuedToInitialize && myRootNodeInitialized; } public void select(final Object @NotNull [] elements, @Nullable final Runnable onDone) { select(elements, onDone, false); } public void select(final Object @NotNull [] elements, @Nullable final Runnable onDone, boolean addToSelection) { select(elements, onDone, addToSelection, false); } public void select(final Object @NotNull [] elements, @Nullable final Runnable onDone, boolean addToSelection, boolean deferred) { _select(elements, onDone, addToSelection, true, false, true, deferred, false, false); } void _select(final Object @NotNull [] elements, final Runnable onDone, final boolean addToSelection, final boolean checkIfInStructure) { _select(elements, onDone, addToSelection, true, checkIfInStructure, true, false, false, false); } void _select(final Object @NotNull [] elements, @NotNull Runnable onDone) { _select(elements, onDone, false, true, true, false, false, false, false); } public void userSelect(final Object @NotNull [] elements, final Runnable onDone, final boolean addToSelection, boolean scroll) { _select(elements, onDone, addToSelection, true, false, scroll, false, true, true); } void _select(final Object @NotNull [] elements, final Runnable onDone, final boolean addToSelection, final boolean checkCurrentSelection, final boolean checkIfInStructure, final boolean scrollToVisible, final boolean deferred, final boolean canSmartExpand, final boolean mayQueue) { assertIsDispatchThread(); AbstractTreeUpdater updater = getUpdater(); if (mayQueue && updater != null) { updater.queueSelection( new SelectionRequest(elements, onDone, addToSelection, checkCurrentSelection, checkIfInStructure, scrollToVisible, deferred, canSmartExpand)); return; } boolean willAffectSelection = elements.length > 0 || addToSelection; if (!willAffectSelection) { runDone(onDone); maybeReady(); return; } final boolean oldCanProcessDeferredSelection = myCanProcessDeferredSelections; if (!deferred && wasRootNodeInitialized()) { _getReady().doWhenDone(new TreeRunnable("AbstractTreeUi._select: on done getReady") { @Override public void perform() { myCanProcessDeferredSelections = false; } }); } if (!checkDeferred(deferred, onDone)) return; if (!deferred && oldCanProcessDeferredSelection && !myCanProcessDeferredSelections) { if (!addToSelection) { getTree().clearSelection(); } } runDone(new TreeRunnable("AbstractTreeUi._select") { @Override public void perform() { try { if (!checkDeferred(deferred, onDone)) return; final Set<Object> currentElements = getSelectedElements(); if (checkCurrentSelection && !currentElements.isEmpty() && elements.length == currentElements.size()) { boolean runSelection = false; for (Object eachToSelect : elements) { if (!currentElements.contains(eachToSelect)) { runSelection = true; break; } } if (!runSelection) { selectVisible(elements[0], onDone, false, false, scrollToVisible); return; } } clearSelection(); Set<Object> toSelect = new HashSet<>(); ContainerUtil.addAllNotNull(toSelect, elements); if (addToSelection) { ContainerUtil.addAllNotNull(toSelect, currentElements); } if (checkIfInStructure) { toSelect.removeIf(each -> !isInStructure(each)); } final Object[] elementsToSelect = ArrayUtil.toObjectArray(toSelect); if (wasRootNodeInitialized()) { final int[] originalRows = myTree.getSelectionRows(); if (!addToSelection) { clearSelection(); } addNext(elementsToSelect, 0, new TreeRunnable("AbstractTreeUi._select: addNext") { @Override public void perform() { if (getTree().isSelectionEmpty()) { processInnerChange(new TreeRunnable("AbstractTreeUi._select: addNext: processInnerChange") { @Override public void perform() { restoreSelection(currentElements); } }); } runDone(onDone); } }, originalRows, deferred, scrollToVisible, canSmartExpand); } else { addToDeferred(elementsToSelect, onDone, addToSelection); } } finally { maybeReady(); } } }); } private void clearSelection() { mySelectionIsBeingAdjusted = true; try { myTree.clearSelection(); } finally { mySelectionIsBeingAdjusted = false; } } boolean isSelectionBeingAdjusted() { return mySelectionIsBeingAdjusted; } private void restoreSelection(@NotNull Set<Object> selection) { for (Object each : selection) { DefaultMutableTreeNode node = getNodeForElement(each, false); if (node != null && isValidForSelectionAdjusting(node)) { addSelectionPath(getPathFor(node), false, null, null); } } } private void addToDeferred(final Object @NotNull [] elementsToSelect, final Runnable onDone, final boolean addToSelection) { if (!addToSelection) { myDeferredSelections.clear(); } myDeferredSelections.add(new TreeRunnable("AbstractTreeUi.addToDeferred") { @Override public void perform() { select(elementsToSelect, onDone, addToSelection, true); } }); } private boolean checkDeferred(boolean isDeferred, @Nullable Runnable onDone) { if (!isDeferred || myCanProcessDeferredSelections || !wasRootNodeInitialized()) { return true; } else { runDone(onDone); return false; } } @NotNull final Set<Object> getSelectedElements() { TreePath[] paths = myTree.getSelectionPaths(); Set<Object> result = new LinkedHashSet<>(); if (paths != null) { for (TreePath eachPath : paths) { if (eachPath.getLastPathComponent() instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode eachNode = (DefaultMutableTreeNode)eachPath.getLastPathComponent(); if (eachNode == myRootNode && !myTree.isRootVisible()) continue; Object eachElement = getElementFor(eachNode); if (eachElement != null) { result.add(eachElement); } } } } return result; } private void addNext(final Object @NotNull [] elements, final int i, @Nullable final Runnable onDone, final int[] originalRows, final boolean deferred, final boolean scrollToVisible, final boolean canSmartExpand) { if (i >= elements.length) { if (myTree.isSelectionEmpty()) { myTree.setSelectionRows(originalRows); } runDone(onDone); } else { if (!checkDeferred(deferred, onDone)) { return; } doSelect(elements[i], new TreeRunnable("AbstractTreeUi.addNext") { @Override public void perform() { if (!checkDeferred(deferred, onDone)) return; addNext(elements, i + 1, onDone, originalRows, deferred, scrollToVisible, canSmartExpand); } }, deferred, i == 0, scrollToVisible, canSmartExpand); } } public void select(@Nullable Object element, @Nullable final Runnable onDone) { select(element, onDone, false); } public void select(@Nullable Object element, @Nullable final Runnable onDone, boolean addToSelection) { if (element == null) return; _select(new Object[]{element}, onDone, addToSelection, false); } private void doSelect(@NotNull final Object element, final Runnable onDone, final boolean deferred, final boolean canBeCentered, final boolean scrollToVisible, final boolean canSmartExpand) { final Runnable _onDone = new TreeRunnable("AbstractTreeUi.doSelect") { @Override public void perform() { if (!checkDeferred(deferred, onDone)) return; checkPathAndMaybeRevalidate(element, new TreeRunnable("AbstractTreeUi.doSelect: checkPathAndMaybeRevalidate") { @Override public void perform() { selectVisible(element, onDone, true, canBeCentered, scrollToVisible); } }, true, canSmartExpand); } }; _expand(element, _onDone, true, false, canSmartExpand); } private void checkPathAndMaybeRevalidate(@NotNull Object element, @NotNull final Runnable onDone, final boolean parentsOnly, final boolean canSmartExpand) { boolean toRevalidate = isValid(element) && !myRevalidatedObjects.contains(element) && getNodeForElement(element, false) == null && isInStructure(element); if (!toRevalidate) { runDone(onDone); return; } myRevalidatedObjects.add(element); getBuilder() .revalidateElement(element) .onSuccess(o -> invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeUi.checkPathAndMaybeRevalidate: on done revalidateElement") { @Override public void perform() { _expand(o, onDone, parentsOnly, false, canSmartExpand); } })) .onError(throwable -> wrapDone(onDone, "AbstractTreeUi.checkPathAndMaybeRevalidate: on rejected revalidateElement").run()); } public void scrollSelectionToVisible(@Nullable final Runnable onDone, final boolean shouldBeCentered) { //noinspection SSBasedInspection SwingUtilities.invokeLater(new TreeRunnable("AbstractTreeUi.scrollSelectionToVisible") { @Override public void perform() { if (isReleased()) return; int[] rows = myTree.getSelectionRows(); if (rows == null || rows.length == 0) { runDone(onDone); return; } Object toSelect = null; for (int eachRow : rows) { TreePath path = myTree.getPathForRow(eachRow); toSelect = getElementFor(path.getLastPathComponent()); if (toSelect != null) break; } if (toSelect != null) { selectVisible(toSelect, onDone, true, shouldBeCentered, true); } } }); } private void selectVisible(@NotNull Object element, final Runnable onDone, boolean addToSelection, boolean canBeCentered, final boolean scroll) { DefaultMutableTreeNode toSelect = getNodeToScroll(element); if (toSelect == null) { runDone(onDone); return; } if (myUpdaterState != null) { myUpdaterState.addSelection(element); } setHoldSize(false); runDone(wrapScrollTo(onDone, element, toSelect, addToSelection, canBeCentered, scroll)); } void userScrollTo(Object element, Runnable onDone) { DefaultMutableTreeNode node = getNodeToScroll(element); runDone(node == null ? onDone : wrapScrollTo(onDone, element, node, false, true, true)); } private DefaultMutableTreeNode getNodeToScroll(Object element) { if (element == null) return null; DefaultMutableTreeNode node = getNodeForElement(element, false); if (node == null) return null; return myTree.isRootVisible() || node != getRootNode() ? node : null; } @NotNull private Runnable wrapDone(Runnable onDone, @NotNull String name) { return new TreeRunnable(name) { @Override public void perform() { runDone(onDone); } }; } @NotNull private Runnable wrapScrollTo(Runnable onDone, @NotNull Object element, @NotNull DefaultMutableTreeNode node, boolean addToSelection, boolean canBeCentered, boolean scroll) { return new TreeRunnable("AbstractTreeUi.wrapScrollTo") { @Override public void perform() { int row = getRowIfUnderSelection(element); if (row == -1) row = myTree.getRowForPath(new TreePath(node.getPath())); int top = row - 2; int bottom = row + 2; if (canBeCentered && Registry.is("ide.tree.autoscrollToVCenter")) { int count = TreeUtil.getVisibleRowCount(myTree) - 1; top = count > 0 ? row - count / 2 : row; bottom = count > 0 ? top + count : row; } TreeUtil.showAndSelect(myTree, top, bottom, row, -1, addToSelection, scroll) .doWhenDone(wrapDone(onDone, "AbstractTreeUi.wrapScrollTo.onDone")); } }; } private int getRowIfUnderSelection(@NotNull Object element) { final Set<Object> selection = getSelectedElements(); if (selection.contains(element)) { final TreePath[] paths = getTree().getSelectionPaths(); for (TreePath each : paths) { if (element.equals(getElementFor(each.getLastPathComponent()))) { return getTree().getRowForPath(each); } } return -1; } Object anchor = TreeAnchorizer.getService().createAnchor(element); Object o = isNodeNull(anchor) ? null : myElementToNodeMap.get(anchor); TreeAnchorizer.getService().freeAnchor(anchor); if (o instanceof List) { final TreePath[] paths = getTree().getSelectionPaths(); if (paths != null && paths.length > 0) { Set<DefaultMutableTreeNode> selectedNodes = new HashSet<>(); for (TreePath eachPAth : paths) { if (eachPAth.getLastPathComponent() instanceof DefaultMutableTreeNode) { selectedNodes.add((DefaultMutableTreeNode)eachPAth.getLastPathComponent()); } } //noinspection unchecked for (DefaultMutableTreeNode eachNode : (List<DefaultMutableTreeNode>)o) { while (eachNode != null) { if (selectedNodes.contains(eachNode)) { return getTree().getRowForPath(getPathFor(eachNode)); } eachNode = (DefaultMutableTreeNode)eachNode.getParent(); } } } } return -1; } public void expandAll(@Nullable final Runnable onDone) { final JTree tree = getTree(); if (tree.getRowCount() > 0) { final int expandRecursionDepth = Math.max(2, Registry.intValue("ide.tree.expandRecursionDepth")); new TreeRunnable("AbstractTreeUi.expandAll") { private int myCurrentRow; private int myInvocationCount; @Override public void perform() { if (++myInvocationCount > expandRecursionDepth) { myInvocationCount = 0; if (isPassthroughMode()) { run(); } else { // need this to prevent stack overflow if the tree is rather big and is "synchronous" //noinspection SSBasedInspection SwingUtilities.invokeLater(this); } } else { final int row = myCurrentRow++; if (row < tree.getRowCount()) { final TreePath path = tree.getPathForRow(row); final Object last = path.getLastPathComponent(); final Object elem = getElementFor(last); expand(elem, this); } else { runDone(onDone); } } } }.run(); } else { runDone(onDone); } } public void expand(final Object element, @Nullable final Runnable onDone) { expand(new Object[]{element}, onDone); } public void expand(final Object @NotNull [] element, @Nullable final Runnable onDone) { expand(element, onDone, false); } void expand(final Object @NotNull [] element, @Nullable final Runnable onDone, boolean checkIfInStructure) { _expand(element, onDone == null ? new EmptyRunnable() : onDone, checkIfInStructure); } private void _expand(final Object @NotNull [] elements, @NotNull final Runnable onDone, final boolean checkIfInStructure) { try { runDone(new TreeRunnable("AbstractTreeUi._expand") { @Override public void perform() { if (elements.length == 0) { runDone(onDone); return; } if (myUpdaterState != null) { myUpdaterState.clearExpansion(); } final ActionCallback done = new ActionCallback(elements.length); done .doWhenDone(wrapDone(onDone, "AbstractTreeUi._expand: on done expandNext")) .doWhenRejected(wrapDone(onDone, "AbstractTreeUi._expand: on rejected expandNext")); expandNext(elements, 0, false, checkIfInStructure, false, done, 0); } }); } catch (ProcessCanceledException e) { try { runDone(onDone); } catch (ProcessCanceledException ignored) { //todo[kirillk] added by Nik to fix IDEA-58475. I'm not sure that it is correct solution } } } private void expandNext(final Object @NotNull [] elements, final int index, final boolean parentsOnly, final boolean checkIfInStricture, final boolean canSmartExpand, @NotNull final ActionCallback done, final int currentDepth) { if (elements.length <= 0) { done.setDone(); return; } if (index >= elements.length) { return; } final int[] actualDepth = {currentDepth}; boolean breakCallChain = false; if (actualDepth[0] > Registry.intValue("ide.tree.expandRecursionDepth")) { actualDepth[0] = 0; breakCallChain = true; } Runnable expandRunnable = new TreeRunnable("AbstractTreeUi.expandNext") { @Override public void perform() { _expand(elements[index], new TreeRunnable("AbstractTreeUi.expandNext: on done") { @Override public void perform() { done.setDone(); expandNext(elements, index + 1, parentsOnly, checkIfInStricture, canSmartExpand, done, actualDepth[0] + 1); } }, parentsOnly, checkIfInStricture, canSmartExpand); } }; if (breakCallChain && !isPassthroughMode()) { //noinspection SSBasedInspection SwingUtilities.invokeLater(expandRunnable); } else { expandRunnable.run(); } } public void collapseChildren(@NotNull final Object element, @Nullable final Runnable onDone) { runDone(new TreeRunnable("AbstractTreeUi.collapseChildren") { @Override public void perform() { final DefaultMutableTreeNode node = getNodeForElement(element, false); if (node != null) { getTree().collapsePath(new TreePath(node.getPath())); runDone(onDone); } } }); } private void runDone(@Nullable Runnable done) { if (done == null) return; if (!canInitiateNewActivity()) { if (done instanceof AbstractTreeBuilder.UserRunnable) { return; } } if (isYeildingNow()) { myYieldingDoneRunnables.add(done); } else { try { execute(done); } catch (ProcessCanceledException ignored) { } } } private void _expand(final Object element, @NotNull final Runnable onDone, final boolean parentsOnly, boolean checkIfInStructure, boolean canSmartExpand) { if (checkIfInStructure && !isInStructure(element)) { runDone(onDone); return; } if (wasRootNodeInitialized()) { List<Object> kidsToExpand = new ArrayList<>(); Object eachElement = element; DefaultMutableTreeNode firstVisible = null; while (true) { if (eachElement == null || !isValid(eachElement)) break; final int preselected = getRowIfUnderSelection(eachElement); if (preselected >= 0) { firstVisible = (DefaultMutableTreeNode)getTree().getPathForRow(preselected).getLastPathComponent(); } else { firstVisible = getNodeForElement(eachElement, true); } if (eachElement != element || !parentsOnly) { kidsToExpand.add(eachElement); } if (firstVisible != null) break; eachElement = getTreeStructure().getParentElement(eachElement); if (eachElement == null) break; int i = kidsToExpand.indexOf(eachElement); if (i != -1) { try { Object existing = kidsToExpand.get(i); LOG.error("Tree path contains equal elements at different levels:\n" + " element: '" + eachElement + "'; " + eachElement.getClass() + " ("+System.identityHashCode(eachElement)+");\n" + "existing: '" + existing + "'; " + existing.getClass()+ " ("+System.identityHashCode(existing)+"); " + "path='" + kidsToExpand + "'; tree structure=" + myTreeStructure); } catch (AssertionError ignored) { } runDone(onDone); throw new ProcessCanceledException(); } } if (firstVisible == null) { runDone(onDone); } else if (kidsToExpand.isEmpty()) { final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)firstVisible.getParent(); if (parentNode != null) { final TreePath parentPath = new TreePath(parentNode.getPath()); if (!myTree.isExpanded(parentPath)) { expand(parentPath, canSmartExpand); } } runDone(onDone); } else { processExpand(firstVisible, kidsToExpand, kidsToExpand.size() - 1, onDone, canSmartExpand); } } else { deferExpansion(element, onDone, parentsOnly, canSmartExpand); } } private void deferExpansion(final Object element, @NotNull final Runnable onDone, final boolean parentsOnly, final boolean canSmartExpand) { myDeferredExpansions.add(new TreeRunnable("AbstractTreeUi.deferExpansion") { @Override public void perform() { _expand(element, onDone, parentsOnly, false, canSmartExpand); } }); } private void processExpand(final DefaultMutableTreeNode toExpand, @NotNull final List<Object> kidsToExpand, final int expandIndex, @NotNull final Runnable onDone, final boolean canSmartExpand) { final Object element = getElementFor(toExpand); if (element == null) { runDone(onDone); return; } addNodeAction(element, true, node -> { if (node.getChildCount() > 0 && !myTree.isExpanded(new TreePath(node.getPath()))) { if (!isAutoExpand(node)) { expand(node, canSmartExpand); } } if (expandIndex <= 0) { runDone(onDone); return; } checkPathAndMaybeRevalidate(kidsToExpand.get(expandIndex - 1), new TreeRunnable("AbstractTreeUi.processExpand") { @Override public void perform() { final DefaultMutableTreeNode nextNode = getNodeForElement(kidsToExpand.get(expandIndex - 1), false); processExpand(nextNode, kidsToExpand, expandIndex - 1, onDone, canSmartExpand); } }, false, canSmartExpand); }); boolean childrenToUpdate = areChildrenToBeUpdated(toExpand); boolean expanded = myTree.isExpanded(getPathFor(toExpand)); boolean unbuilt = myUnbuiltNodes.contains(toExpand); if (expanded) { if (unbuilt || childrenToUpdate) { addSubtreeToUpdate(toExpand); } } else { expand(toExpand, canSmartExpand); } if (!unbuilt && !childrenToUpdate) { processNodeActionsIfReady(toExpand); } } private boolean areChildrenToBeUpdated(DefaultMutableTreeNode node) { return getUpdater().isEnqueuedToUpdate(node) || isUpdatingParent(node) || myCancelledBuild.containsKey(node); } @Nullable public Object getElementFor(Object node) { NodeDescriptor descriptor = getDescriptorFrom(node); return descriptor == null ? null : getElementFromDescriptor(descriptor); } final boolean isNodeBeingBuilt(@NotNull final TreePath path) { return isNodeBeingBuilt(path.getLastPathComponent()); } private boolean isNodeBeingBuilt(@NotNull Object node) { return getParentBuiltNode(node) != null || myRootNode == node && !wasRootNodeInitialized(); } @Nullable private DefaultMutableTreeNode getParentBuiltNode(@NotNull Object node) { DefaultMutableTreeNode parent = getParentLoadingInBackground(node); if (parent != null) return parent; if (isLoadingParentInBackground(node)) return (DefaultMutableTreeNode)node; DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node; final boolean childrenAreNoLoadedYet = myUnbuiltNodes.contains(treeNode) || isUpdatingChildrenNow(treeNode); if (childrenAreNoLoadedYet) { final TreePath nodePath = new TreePath(treeNode.getPath()); if (!myTree.isExpanded(nodePath)) return null; return (DefaultMutableTreeNode)node; } return null; } private boolean isLoadingParentInBackground(Object node) { return node instanceof DefaultMutableTreeNode && isLoadedInBackground(getElementFor(node)); } public void setTreeStructure(@NotNull AbstractTreeStructure treeStructure) { myTreeStructure = treeStructure; clearUpdaterState(); } public AbstractTreeUpdater getUpdater() { return myUpdater; } public void setUpdater(@Nullable final AbstractTreeUpdater updater) { myUpdater = updater; if (updater != null && myUpdateIfInactive) { updater.showNotify(); } if (myUpdater != null) { myUpdater.setPassThroughMode(myPassThroughMode); } } public DefaultMutableTreeNode getRootNode() { return myRootNode; } public void setRootNode(@NotNull final DefaultMutableTreeNode rootNode) { myRootNode = rootNode; } private void dropUpdaterStateIfExternalChange() { if (!isInnerChange()) { clearUpdaterState(); myAutoExpandRoots.clear(); mySelectionIsAdjusted = false; } } void clearUpdaterState() { myUpdaterState = null; } private void createMapping(@NotNull Object element, DefaultMutableTreeNode node) { element = TreeAnchorizer.getService().createAnchor(element); warnMap("myElementToNodeMap: createMapping: ", myElementToNodeMap); if (!myElementToNodeMap.containsKey(element)) { myElementToNodeMap.put(element, node); } else { final Object value = myElementToNodeMap.get(element); final List<DefaultMutableTreeNode> nodes; if (value instanceof DefaultMutableTreeNode) { nodes = new ArrayList<>(); nodes.add((DefaultMutableTreeNode)value); myElementToNodeMap.put(element, nodes); } else { nodes = (List<DefaultMutableTreeNode>)value; } nodes.add(node); } } private void removeMapping(@NotNull Object element, DefaultMutableTreeNode node, @Nullable Object elementToPutNodeActionsFor) { element = TreeAnchorizer.getService().createAnchor(element); warnMap("myElementToNodeMap: removeMapping: ", myElementToNodeMap); final Object value = myElementToNodeMap.get(element); if (value != null) { if (value instanceof DefaultMutableTreeNode) { if (value.equals(node)) { myElementToNodeMap.remove(element); } } else { List<DefaultMutableTreeNode> nodes = (List<DefaultMutableTreeNode>)value; final boolean reallyRemoved = nodes.remove(node); if (reallyRemoved) { if (nodes.isEmpty()) { myElementToNodeMap.remove(element); } } } } remapNodeActions(element, elementToPutNodeActionsFor); TreeAnchorizer.getService().freeAnchor(element); } private void remapNodeActions(Object element, Object elementToPutNodeActionsFor) { _remapNodeActions(element, elementToPutNodeActionsFor, myNodeActions); _remapNodeActions(element, elementToPutNodeActionsFor, myNodeChildrenActions); warnMap("myNodeActions: remapNodeActions: ", myNodeActions); warnMap("myNodeChildrenActions: remapNodeActions: ", myNodeChildrenActions); } private static void _remapNodeActions(Object element, @Nullable Object elementToPutNodeActionsFor, @NotNull final Map<Object, List<NodeAction>> nodeActions) { final List<NodeAction> actions = nodeActions.get(element); nodeActions.remove(element); if (elementToPutNodeActionsFor != null && actions != null) { nodeActions.put(elementToPutNodeActionsFor, actions); } } @Nullable private DefaultMutableTreeNode getFirstNode(@NotNull Object element) { return findNode(element, 0); } @Nullable private DefaultMutableTreeNode findNode(@NotNull Object element, int startIndex) { final Object value = getBuilder().findNodeByElement(element); if (value == null) { return null; } if (value instanceof DefaultMutableTreeNode) { return startIndex == 0 ? (DefaultMutableTreeNode)value : null; } final List<DefaultMutableTreeNode> nodes = (List<DefaultMutableTreeNode>)value; return startIndex < nodes.size() ? nodes.get(startIndex) : null; } Object findNodeByElement(Object element) { element = TreeAnchorizer.getService().createAnchor(element); try { if (isNodeNull(element)) return null; if (myElementToNodeMap.containsKey(element)) { return myElementToNodeMap.get(element); } TREE_NODE_WRAPPER.setValue(element); return myElementToNodeMap.get(TREE_NODE_WRAPPER); } finally { TREE_NODE_WRAPPER.setValue(null); TreeAnchorizer.getService().freeAnchor(element); } } @Nullable private DefaultMutableTreeNode findNodeForChildElement(@NotNull DefaultMutableTreeNode parentNode, Object element) { Object anchor = TreeAnchorizer.getService().createAnchor(element); final Object value = isNodeNull(anchor) ? null : myElementToNodeMap.get(anchor); TreeAnchorizer.getService().freeAnchor(anchor); if (value == null) { return null; } if (value instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode elementNode = (DefaultMutableTreeNode)value; return parentNode.equals(elementNode.getParent()) ? elementNode : null; } final List<DefaultMutableTreeNode> allNodesForElement = (List<DefaultMutableTreeNode>)value; for (final DefaultMutableTreeNode elementNode : allNodesForElement) { if (parentNode.equals(elementNode.getParent())) { return elementNode; } } return null; } private void addNodeAction(Object element, boolean shouldChildrenBeReady, @NotNull NodeAction action) { _addNodeAction(element, action, myNodeActions); if (shouldChildrenBeReady) { _addNodeAction(element, action, myNodeChildrenActions); } warnMap("myNodeActions: addNodeAction: ", myNodeActions); warnMap("myNodeChildrenActions: addNodeAction: ", myNodeChildrenActions); } public void addActivity() { if (myActivityMonitor != null) { myActivityMonitor.addActivity(myActivityId, getUpdater().getModalityState()); } } private void removeActivity() { if (myActivityMonitor != null) { myActivityMonitor.removeActivity(myActivityId); } } private void _addNodeAction(Object element, NodeAction action, @NotNull Map<Object, List<NodeAction>> map) { maybeSetBusyAndScheduleWaiterForReady(true, element); map.computeIfAbsent(element, k -> new ArrayList<>()).add(action); addActivity(); } private void cleanUpNow() { if (!canInitiateNewActivity()) return; final UpdaterTreeState state = new UpdaterTreeState(this); myTree.collapsePath(new TreePath(myTree.getModel().getRoot())); clearSelection(); getRootNode().removeAllChildren(); TREE_NODE_WRAPPER = AbstractTreeBuilder.createSearchingTreeNodeWrapper(); myRootNodeWasQueuedToInitialize = false; myRootNodeInitialized = false; clearNodeActions(); myElementToNodeMap.clear(); myDeferredSelections.clear(); myDeferredExpansions.clear(); myLoadedInBackground.clear(); myUnbuiltNodes.clear(); myUpdateFromRootRequested = true; myWorker.clear(); myTree.invalidate(); state.restore(null); } public void setClearOnHideDelay(final long clearOnHideDelay) { myClearOnHideDelay = clearOnHideDelay; } private class MySelectionListener implements TreeSelectionListener { @Override public void valueChanged(@NotNull final TreeSelectionEvent e) { if (mySilentSelect != null && mySilentSelect.equals(e.getNewLeadSelectionPath())) return; dropUpdaterStateIfExternalChange(); } } private class MyExpansionListener implements TreeExpansionListener { @Override public void treeExpanded(@NotNull TreeExpansionEvent event) { final TreePath path = event.getPath(); if (mySilentExpand != null && mySilentExpand.equals(path)) return; dropUpdaterStateIfExternalChange(); if (myRequestedExpand != null && !myRequestedExpand.equals(path)) { _getReady().doWhenDone(new TreeRunnable("AbstractTreeUi.MyExpansionListener.treeExpanded") { @Override public void perform() { Object element = getElementFor(path.getLastPathComponent()); expand(element, null); } }); return; } final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (!myUnbuiltNodes.contains(node)) { removeLoading(node, false); Set<DefaultMutableTreeNode> childrenToUpdate = new HashSet<>(); for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode each = (DefaultMutableTreeNode)node.getChildAt(i); if (myUnbuiltNodes.contains(each)) { makeLoadingOrLeafIfNoChildren(each); childrenToUpdate.add(each); } } if (!childrenToUpdate.isEmpty()) { for (DefaultMutableTreeNode each : childrenToUpdate) { maybeUpdateSubtreeToUpdate(each); } } } else { getBuilder().expandNodeChildren(node); } processSmartExpand(node, canSmartExpand(node, true), false); processNodeActionsIfReady(node); } @Override public void treeCollapsed(@NotNull TreeExpansionEvent e) { dropUpdaterStateIfExternalChange(); final TreePath path = e.getPath(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); NodeDescriptor descriptor = getDescriptorFrom(node); if (descriptor == null) return; TreePath pathToSelect = null; if (isSelectionInside(node)) { pathToSelect = new TreePath(node.getPath()); } if (getBuilder().isDisposeOnCollapsing(descriptor)) { runDone(new TreeRunnable("AbstractTreeUi.MyExpansionListener.treeCollapsed") { @Override public void perform() { if (isDisposed(node)) return; TreePath nodePath = new TreePath(node.getPath()); if (myTree.isExpanded(nodePath)) return; removeChildren(node); makeLoadingOrLeafIfNoChildren(node); } }); if (node.equals(getRootNode())) { if (myTree.isRootVisible()) { //todo kirillk to investigate -- should be done by standard selction move //addSelectionPath(new TreePath(getRootNode().getPath()), true, Condition.FALSE); } } else { myTreeModel.reload(node); } } if (pathToSelect != null && myTree.isSelectionEmpty()) { addSelectionPath(pathToSelect, true, Conditions.alwaysFalse(), null); } } } private void removeChildren(@NotNull DefaultMutableTreeNode node) { @SuppressWarnings({"unchecked", "rawtypes"}) Enumeration<DefaultMutableTreeNode> children = (Enumeration)node.children(); for (DefaultMutableTreeNode child : Collections.list(children)) { disposeNode(child); } node.removeAllChildren(); nodeStructureChanged(node); } private void maybeUpdateSubtreeToUpdate(@NotNull final DefaultMutableTreeNode subtreeRoot) { if (!myUnbuiltNodes.contains(subtreeRoot)) return; TreePath path = getPathFor(subtreeRoot); if (myTree.getRowForPath(path) == -1) return; DefaultMutableTreeNode parent = getParentBuiltNode(subtreeRoot); if (parent == null) { if (!getBuilder().isAlwaysShowPlus(getDescriptorFrom(subtreeRoot))) { addSubtreeToUpdate(subtreeRoot); } } else if (parent != subtreeRoot) { addNodeAction(getElementFor(subtreeRoot), true, parent1 -> maybeUpdateSubtreeToUpdate(subtreeRoot)); } } private boolean isSelectionInside(@NotNull DefaultMutableTreeNode parent) { TreePath path = new TreePath(myTreeModel.getPathToRoot(parent)); TreePath[] paths = myTree.getSelectionPaths(); if (paths == null) return false; for (TreePath path1 : paths) { if (path.isDescendant(path1)) return true; } return false; } boolean isInStructure(@Nullable Object element) { if (isNodeNull(element)) return false; final AbstractTreeStructure structure = getTreeStructure(); if (structure == null) return false; final Object rootElement = structure.getRootElement(); Object eachParent = element; while (eachParent != null) { if (Comparing.equal(rootElement, eachParent)) return true; eachParent = structure.getParentElement(eachParent); } return false; } @FunctionalInterface interface NodeAction { void onReady(@NotNull DefaultMutableTreeNode node); } void setCanYield(final boolean canYield) { myCanYield = canYield; } @NotNull Collection<TreeUpdatePass> getYeildingPasses() { return myYieldingPasses; } private static class LoadedChildren { @NotNull private final List<Object> myElements; private final Map<Object, NodeDescriptor> myDescriptors = new HashMap<>(); private final Map<NodeDescriptor, Boolean> myChanges = new HashMap<>(); LoadedChildren(Object @Nullable [] elements) { myElements = Arrays.asList(elements != null ? elements : ArrayUtilRt.EMPTY_OBJECT_ARRAY); } void putDescriptor(Object element, NodeDescriptor descriptor, boolean isChanged) { if (isUnitTestingMode()) { assert myElements.contains(element); } myDescriptors.put(element, descriptor); myChanges.put(descriptor, isChanged); } @NotNull List<Object> getElements() { return myElements; } NodeDescriptor getDescriptor(Object element) { return myDescriptors.get(element); } @NotNull @Override public String toString() { return myElements + "->" + myChanges; } public boolean isUpdated(Object element) { NodeDescriptor desc = getDescriptor(element); return myChanges.get(desc); } } private long getComparatorStamp() { if (myNodeDescriptorComparator instanceof NodeDescriptor.NodeComparator) { long currentComparatorStamp = ((NodeDescriptor.NodeComparator)myNodeDescriptorComparator).getStamp(); if (currentComparatorStamp > myLastComparatorStamp) { myOwnComparatorStamp = Math.max(myOwnComparatorStamp, currentComparatorStamp) + 1; } myLastComparatorStamp = currentComparatorStamp; return Math.max(currentComparatorStamp, myOwnComparatorStamp); } else { return myOwnComparatorStamp; } } void incComparatorStamp() { myOwnComparatorStamp = getComparatorStamp() + 1; } private static class UpdateInfo { NodeDescriptor myDescriptor; TreeUpdatePass myPass; boolean myCanSmartExpand; boolean myWasExpanded; boolean myForceUpdate; boolean myDescriptorIsUpToDate; boolean myUpdateChildren; UpdateInfo(NodeDescriptor descriptor, TreeUpdatePass pass, boolean canSmartExpand, boolean wasExpanded, boolean forceUpdate, boolean descriptorIsUpToDate, boolean updateChildren) { myDescriptor = descriptor; myPass = pass; myCanSmartExpand = canSmartExpand; myWasExpanded = wasExpanded; myForceUpdate = forceUpdate; myDescriptorIsUpToDate = descriptorIsUpToDate; myUpdateChildren = updateChildren; } synchronized NodeDescriptor getDescriptor() { return myDescriptor; } synchronized TreeUpdatePass getPass() { return myPass; } synchronized boolean isCanSmartExpand() { return myCanSmartExpand; } synchronized boolean isWasExpanded() { return myWasExpanded; } synchronized boolean isForceUpdate() { return myForceUpdate; } synchronized boolean isDescriptorIsUpToDate() { return myDescriptorIsUpToDate; } public synchronized void apply(@NotNull UpdateInfo updateInfo) { myDescriptor = updateInfo.myDescriptor; myPass = updateInfo.myPass; myCanSmartExpand = updateInfo.myCanSmartExpand; myWasExpanded = updateInfo.myWasExpanded; myForceUpdate = updateInfo.myForceUpdate; myDescriptorIsUpToDate = updateInfo.myDescriptorIsUpToDate; } public synchronized boolean isUpdateChildren() { return myUpdateChildren; } @Override @NotNull @NonNls public synchronized String toString() { return "UpdateInfo: desc=" + myDescriptor + " pass=" + myPass + " canSmartExpand=" + myCanSmartExpand + " wasExpanded=" + myWasExpanded + " forceUpdate=" + myForceUpdate + " descriptorUpToDate=" + myDescriptorIsUpToDate; } } void setPassthroughMode(boolean passthrough) { myPassThroughMode = passthrough; AbstractTreeUpdater updater = getUpdater(); if (updater != null) { updater.setPassThroughMode(myPassThroughMode); } if (!isUnitTestingMode() && passthrough) { // TODO: this assertion should be restored back as soon as possible [JamTreeTableView should be rewritten, etc] //LOG.error("Pass-through mode for TreeUi is allowed only for unit test mode"); } } boolean isPassthroughMode() { return myPassThroughMode; } private static boolean isUnitTestingMode() { Application app = ApplicationManager.getApplication(); return app != null && app.isUnitTestMode(); } private void addModelListenerToDiagnoseAccessOutsideEdt() { myTreeModel.addTreeModelListener(new TreeModelListener() { @Override public void treeNodesChanged(TreeModelEvent e) { assertIsDispatchThread(); } @Override public void treeNodesInserted(TreeModelEvent e) { assertIsDispatchThread(); } @Override public void treeNodesRemoved(TreeModelEvent e) { assertIsDispatchThread(); } @Override public void treeStructureChanged(TreeModelEvent e) { assertIsDispatchThread(); } }); } private <V> void warnMap(String prefix, Map<Object, V> map) { if (!LOG.isDebugEnabled()) return; if (!SwingUtilities.isEventDispatchThread() && !myPassThroughMode) { LOG.warn(prefix + "modified on wrong thread"); } long count = map.keySet().stream().filter(AbstractTreeUi::isNodeNull).count(); if (count > 0) LOG.warn(prefix + "null keys: " + count + " / " + map.size()); } /** * @param element an element in the tree structure * @return {@code true} if element is {@code null} or if it contains a {@code null} value */ private static boolean isNodeNull(Object element) { if (element instanceof AbstractTreeNode) { AbstractTreeNode node = (AbstractTreeNode)element; element = node.getValue(); } return element == null; } public final boolean isConsistent() { return myTree != null && myTreeModel != null && myTreeModel == myTree.getModel(); } }
dahlstrom-g/intellij-community
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
Java
apache-2.0
162,794
[ 30522, 1013, 1013, 9385, 2456, 1011, 25682, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1996, 15895, 1016, 1012, 1014, 6105, 2008, 2064, 2022, 2179, 1999, 1996, 6105, 5371, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#####Use Case ID: UC-PCS40 #####Use Case Name: Create Procedure Instruction **Level:** User Level Goal **Primary Actors:** Physician, Nurse **Stakeholders:** Physician, Nurse, Patient, Healthcare Provider, Order Filler **Purpose:** The main intent of this use case is to create patient specific test and procedure instructions. **Pre Condition:** User must be identified and authenticated. **Post Condition:** Procedure instruction will be created successfully. **Frequency of Occurrence:** High __________________________________________________________ **Main Success Scenario: (Create Procedure Instruction)** 1. Physician selects a create instruction option. 2. System asks user to specify the patient, test or procedure, source type (such as external source or internal) and instructions content. 3. Physician enters the required fields. 4. System then performs the following actions: * Validates the fields. * Records the procedure instructions * Provides these instructions to the order filler. _______________________________________________________________________________ **Alternate Flows** **Alt-1:** 1. Patient does not exist. 2. Invalid test or procedure. **Alt-2:If source type is external** 1. Repeat 1-3 steps of main scenario. 2. System asks user specify either the hyperlink of the external source or attach external source file containing instructions. 3. Physician specifies the instructions’ external source. 4. Repeat step 4 of the main scenario. ________________________________________________________________________ **Reference Hl7 V3 Interaction Identifiers:** N/A _______________________________________________________________ **Reference CCHIT Criteria:** FN 14.01, AM 10.05, AM 10.06 _______________________________________________________________ **Reference Hl7 RMIM:** [More Details](http://www.hl7.org/implement/standards/product_brief.cfm?product_id=306) N/A _______________________________________________________________ **Reference FHIR Resource:** [More Details](http://www.hl7.org/implement/standards/fhir/resourcelist.html) ![procedure fhir resource](https://f.cloud.github.com/assets/5391320/1378728/cb58d49c-3ad7-11e3-80e9-c0ba143c6262.png) _______________________________________________________________ **Reference CDA Template:** [More Details](http://www.hl7.org/Special/committees/structure/index.cfm) Document Level Template **"Procedure Note"** _______________________________________________________________ **Reference OpenEHR Archetypes (Version 1.4):** [More Details](http://www.openehr.org/ckm/) Procedure (openEhr Archetype) ```Archetype archetype (adl_version=1.4) openEHR-EHR-ACTION.procedure.v1 concept [at0000] -- Procedure undertaken language original_language = <[ISO_639-1::en]> translations = < ["ar-sy"] = < language = <[ISO_639-1::ar-sy]> author = < ["name"] = <"Mona Saleh"> > > ["ru"] = < language = <[ISO_639-1::ru]> author = < ["name"] = <"Art Latyp; Латыпов Артур"> ["organisation"] = <"RusBITech; РусБИТех, Москва"> > accreditation = <"hmm"> > ["pt-br"] = < language = <[ISO_639-1::pt-br]> author = < ["name"] = <"Thiago F. F. Dias"> ["organisation"] = <"FMRP-USP"> > > > description original_author = < ["name"] = <"Ian McNicoll"> ["organisation"] = <"Ocean Informatics, United Kingdom"> ["email"] = <"ian.mcnicoll@oceaninformatics.com"> ["date"] = <"2009-12-03"> > details = < ["pt-br"] = < language = <[ISO_639-1::pt-br]> purpose = <"Para registrar os detalhes sobre um procedimento realizado."> use = <"Usado para registrar informações detalhadas sobre o procedimento realizado em um indivíduo. Informações sobre atividades relacionadas ao procedimento, como a anestesia ou a administração de medicamentos, devem ser registrados em arquétipos de ACTION separados."> keywords = <"procedimento", ...> misuse = <""> copyright = <"© openEHR Foundation"> > ["ar-sy"] = < language = <[ISO_639-1::ar-sy]> purpose = <"لتسجيل تفاصيل حول إجراء طبي تم بالفعل إجراؤه"> use = <"لتسجيل معلومات تفصيلية حول إجراء طبي تم تنفيذه على شخص ما. و ينبغي تسجيل المعلومات حول النشاطات المتعلقة بالنشاطات المتعلقة بالإجراء الطبي, مثل التخدير أو إعطاء الأدوية في نماذج (فعل) منفردة."> keywords = <"الإجراء الطبي", ...> misuse = <""> copyright = <"© openEHR Foundation"> > ["ru"] = < language = <[ISO_639-1::ru]> purpose = <"Для записи сведений об проведенной процедуре"> use = <"Используется для записи подробной информации о процедуре, выполненной пациенту. Информация о действиях, связанных с выполнением процедуры, таких как анестезия или применение лекарств, долдно быть записано в отдельных архетипах типа ДЕЙСТВИЕ"> keywords = <"процедура, выполнение", ...> misuse = <""> copyright = <"© openEHR Foundation"> > ["en"] = < language = <[ISO_639-1::en]> purpose = <"To record details about a procedure that has been performed."> use = <"Use to record detailed information about the procedure that has been carried out on an individual. Information about activities related to the procedure, such as anaesthesia or administration of medications, should be recorded in separate ACTION archetypes."> keywords = <"procedure", ...> misuse = <""> copyright = <"© openEHR Foundation"> > > lifecycle_state = <"AuthorDraft"> other_contributors = <"Heather Leslie, Ocean Informatics, Australia (Editor)", "Ian McNicoll, Ocean Informatics, United Kingdom (Editor)"> other_details = < ["MD5-CAM-1.0.1"] = <"3D7A4FCD75127BBE8C9873FF487C6C44"> > definition ACTION[at0000] matches { -- Procedure undertaken ism_transition matches { ISM_TRANSITION[at0034] matches { -- Request initiated current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::524]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0034]} -- Request initiated } } } ISM_TRANSITION[at0035] matches { -- Request sent current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::524]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0035]} -- Request sent } } } ISM_TRANSITION[at0038] matches { -- Request postponed current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::527]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0038]} -- Request postponed } } } ISM_TRANSITION[at0039] matches { -- Request cancelled current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::528]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0039]} -- Request cancelled } } } ISM_TRANSITION[at0036] matches { -- Procedure scheduled current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::529]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0036]} -- Procedure scheduled } } } ISM_TRANSITION[at0047] matches { -- In progress current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::245]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0047]} -- In progress } } } ISM_TRANSITION[at0040] matches { -- Procedure suspended current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::530]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0040]} -- Procedure suspended } } } ISM_TRANSITION[at0041] matches { -- Procedure aborted current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::531]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0041]} -- Procedure aborted } } } ISM_TRANSITION[at0043] matches { -- Completed current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::532]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0043]} -- Completed } } } ISM_TRANSITION[at0044] matches { -- Report authored current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::532]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0044]} -- Report authored } } } ISM_TRANSITION[at0045] matches { -- Report attested current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::532]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0045]} -- Report attested } } } ISM_TRANSITION[at0046] matches { -- Report sent current_state matches { DV_CODED_TEXT matches { defining_code matches {[openehr::532]} } } careflow_step matches { DV_CODED_TEXT matches { defining_code matches {[local::at0046]} -- Report sent } } } } description matches { ITEM_TREE[at0001] matches { -- Tree items cardinality matches {1..*; unordered} matches { ELEMENT[at0002] matches { -- Procedure value matches { DV_TEXT matches {*} } } ELEMENT[at0014] occurrences matches {0..*} matches { -- Reason/s for procedure value matches { DV_TEXT matches {*} } } ELEMENT[at0051] occurrences matches {0..*} matches { -- Method/Technique value matches { DV_TEXT matches {*} } } ELEMENT[at0049] occurrences matches {0..1} matches { -- Description value matches { DV_TEXT matches {*} } } allow_archetype CLUSTER[at0003] occurrences matches {0..1} matches { -- Procedure Details include archetype_id/value matches {/.*/} } allow_archetype CLUSTER[at0050] occurrences matches {0..1} matches { -- Anatomical site details include archetype_id/value matches {/.*/} } CLUSTER[at0030] occurrences matches {0..1} matches { -- Additional tasks items cardinality matches {1..*; unordered} matches { ELEMENT[at0052] occurrences matches {0..1} matches { -- Task value matches { DV_TEXT matches {*} } } ELEMENT[at0031] occurrences matches {0..*} matches { -- Task description value matches { DV_TEXT matches {*} } } ELEMENT[at0032] occurrences matches {0..*} matches { -- Record of additional task value matches { DV_EHR_URI matches {*} } } } } ELEMENT[at0048] occurrences matches {0..1} matches { -- Outcome value matches { DV_TEXT matches {*} } } ELEMENT[at0004] occurrences matches {0..1} matches { -- Procedure unsuccessful value matches { DV_BOOLEAN matches { value matches {True} } } } ELEMENT[at0018] occurrences matches {0..1} matches {*} ELEMENT[at0015] occurrences matches {0..*} matches { -- Unplanned event value matches { DV_TEXT matches {*} } } ELEMENT[at0006] occurrences matches {0..*} matches { -- Complication value matches { DV_TEXT matches {*} } } ELEMENT[at0058] occurrences matches {0..1} matches { -- Emergency? value matches { DV_BOOLEAN matches { value matches {True, False} } } } ELEMENT[at0005] occurrences matches {0..1} matches { -- Comments value matches { DV_TEXT matches {*} } } ELEMENT[at0013] occurrences matches {0..*} matches { -- Multimedia value matches { DV_MULTIMEDIA matches { media_type matches {[openEHR::]} } } } } } } protocol matches { ITEM_TREE[at0053] matches { -- Tree items cardinality matches {0..*; unordered} matches { ELEMENT[at0054] occurrences matches {0..1} matches { -- Requestor order identifier value matches { DV_TEXT matches {*} } } allow_archetype CLUSTER[at0055] occurrences matches {0..1} matches { -- Requestor include archetype_id/value matches {/.*/} } ELEMENT[at0056] occurrences matches {0..1} matches { -- Receiver order identifier value matches { DV_TEXT matches {*} } } allow_archetype CLUSTER[at0057] occurrences matches {0..1} matches { -- Receiver include archetype_id/value matches {/.*/} } } } } } ontology term_definitions = < ["en"] = < items = < ["at0000"] = < text = <"Procedure undertaken"> description = <"A clinical activity that has been carried out for therapeutic or diagnostic purposes."> > ["at0001"] = < text = <"Tree"> description = <"@ internal @"> > ["at0002"] = < text = <"Procedure"> description = <"The name of the procedure."> > ["at0003"] = < text = <"Procedure Details"> description = <"Detailed structure describing the procedure carried out, including preparation and details about the method and equipment/devices used."> > ["at0004"] = < text = <"Procedure unsuccessful"> description = <"Was the procedure ultimately unsuccessful? True if unsuccessful."> > ["at0005"] = < text = <"Comments"> description = <"Comments about the procedure."> > ["at0006"] = < text = <"Complication"> description = <"Details about any complication arising from the procedure."> > ["at0013"] = < text = <"Multimedia"> description = <"Multimedia representation of the procedure, including images."> > ["at0014"] = < text = <"Reason/s for procedure"> description = <"The reason or indication for the procedure."> > ["at0015"] = < text = <"Unplanned event"> description = <"An unplanned event prior to or related to the procedure, which may affect its execution e.g patient self-removed cannula."> > ["at0018"] = < text = <"Failed attempts"> description = <"The number of failed attempts to perform the procedure."> > ["at0030"] = < text = <"Additional tasks"> description = <"Record information about unplanned or unexpected activities that needed to be done during the procedure. Record the name of the task and a description within this archetype, but detail should be recorded in specific linked INSTRUCTION or ACTION archetypes."> > ["at0031"] = < text = <"Task description"> description = <"Description of additional task performed during the procedure."> > ["at0032"] = < text = <"Record of additional task"> description = <"Link to a detailed record of the additional task."> > ["at0034"] = < text = <"Request initiated"> description = <"Request for procedure is initiated."> > ["at0035"] = < text = <"Request sent"> description = <"Request for procedure sent."> > ["at0036"] = < text = <"Procedure scheduled"> description = <"Procedure has been scheduled."> > ["at0038"] = < text = <"Request postponed"> description = <"Request for procedure is postponed."> > ["at0039"] = < text = <"Request cancelled"> description = <"Procedure request has been cancelled."> > ["at0040"] = < text = <"Procedure suspended"> description = <"Procedure has been suspended."> > ["at0041"] = < text = <"Procedure aborted"> description = <"Procedure has been aborted."> > ["at0043"] = < text = <"Completed"> description = <"Procedure has been completed."> > ["at0044"] = < text = <"Report authored"> description = <"Procedure report has been written."> > ["at0045"] = < text = <"Report attested"> description = <"Procedure report has been attested."> > ["at0046"] = < text = <"Report sent"> description = <"Procedure report has been distributed."> > ["at0047"] = < text = <"In progress"> description = <"Procedure is being carried out."> > ["at0048"] = < text = <"Outcome"> description = <"Outcome of procedure performed."> > ["at0049"] = < text = <"Description"> description = <"Narrative description about the procedure carried out."> > ["at0050"] = < text = <"Anatomical site details"> description = <"Details about the anatomical site of procedure."> > ["at0051"] = < text = <"Method/Technique"> description = <"Identification of specific method or technique used for procedure."> > ["at0052"] = < text = <"Task"> description = <"Name of additional task performed during the procedure."> > ["at0053"] = < text = <"Tree"> description = <"@ internal @"> > ["at0054"] = < text = <"Requestor order identifier"> description = <"The local ID assigned to the order by the healthcare provider or organisation requesting the service."> > ["at0055"] = < text = <"Requestor"> description = <"Details about the healthcare provider or organisation requesting the service."> > ["at0056"] = < text = <"Receiver order identifier"> description = <"The ID assigned to the order by the healthcare provider or organisation receiving the request for service. This is also referred to as Filler Order Identifier."> > ["at0057"] = < text = <"Receiver"> description = <"Details about the healthcare provider or organisation receiving the request for service."> > ["at0058"] = < text = <"Emergency?"> description = <"Was this procedure performed as an emergency? True if Yes."> > > > ["pt-br"] = < items = < ["at0000"] = < text = <"Procedimento realizado"> description = <"Atividade clínica que foi realizada para fins terapêuticos ou diagnósticos."> > ["at0001"] = < text = <"Tree"> description = <"@ internal @"> > ["at0002"] = < text = <"Procedimento"> description = <"Nome do procedimento."> > ["at0003"] = < text = <"Detalhes do procedimento"> description = <"Estrutura detalhada descrevendo o procedimento realizado, incluindo a preparação e detalhes sobre os equipamentos/dispositivos utilizados."> > ["at0004"] = < text = <"Procedimento mal sucedido"> description = <"O procedimento foi realmente mal sucedido? Verdadeiro se foi mal sucedido."> > ["at0005"] = < text = <"Comentários"> description = <"Comentários sobre o procedimento."> > ["at0006"] = < text = <"Complicação"> description = <"Detalhes sobre qualquer complicação provinda do pocedimento."> > ["at0013"] = < text = <"Multimídia"> description = <"Representação multimídia do procedimento, incluindo imagens."> > ["at0014"] = < text = <"Razão(ões) para o procedimento"> description = <"A razão ou indicação para o procedimento."> > ["at0015"] = < text = <"Evento não planejado"> description = <"Um evento não planejado prioritário ou relacionado ao procedimento, o qual pode afetar a sua execução, ex. o próprio paciente removeu a cânula."> > ["at0018"] = < text = <"Tentativas fracassadas"> description = <"Número de tentativas fracassadas para realizar o procedimento."> > ["at0030"] = < text = <"Tarefas adicionais"> description = <"Registro das informações sobre atividades não planejadas ou não esperadas realizadas, que foram necessárias durante o procedimento. Registro do nome da tarefa e a descrição neste arquétipo, mas os detalhes devem ser registrados em um arquétipo específico de INSTRUCTION ou ACTION, ligado a este."> > ["at0031"] = < text = <"Descrição da tarefa"> description = <"Descrição da tarefa realizada durante o procedimento."> > ["at0032"] = < text = <"Registro da tarefa adicional"> description = <"Link para o registro detalhado da tarefa adicional."> > ["at0034"] = < text = <"Pedido iniciado"> description = <"Pedido para o procedimento é iniciado."> > ["at0035"] = < text = <"Pedido enviado"> description = <"Pedido para o procedimento enviado."> > ["at0036"] = < text = <"Procedimento agendado"> description = <"Procedimento foi agendado."> > ["at0038"] = < text = <"Pedido adiado"> description = <"Pedido para o procedimento é adiado."> > ["at0039"] = < text = <"Pedido cancelado"> description = <"Pedido para o procedimento foi cancelado."> > ["at0040"] = < text = <"Procedimento suspenso"> description = <"Procedimento foi suspenso."> > ["at0041"] = < text = <"Procedimento abortado"> description = <"Procedimento foi abortado."> > ["at0043"] = < text = <"Concluido"> description = <"Procedimento foi concluído."> > ["at0044"] = < text = <"Autoria do relatório"> description = <"Relatório do procedimento foi escrito."> > ["at0045"] = < text = <"Relatório atestado"> description = <"Relatório do procedimento foi atestado."> > ["at0046"] = < text = <"Relatório enviado"> description = <"Relatório do procedimento foi distribuído."> > ["at0047"] = < text = <"Em progresso"> description = <"Procedimento está sendo realizado."> > ["at0048"] = < text = <"Resultado"> description = <"Resultado do procedimento realizado."> > ["at0049"] = < text = <"Descrição"> description = <"Narração descritiva sobre o procedimento realizado."> > ["at0050"] = < text = <"Detalhes da região anatômica"> description = <"Detalhes sobre a região anatômica do procedimento."> > ["at0051"] = < text = <"Método/Técnica"> description = <"Identificação do método ou técnica específica utilizada no procedimento."> > ["at0052"] = < text = <"Tarefa"> description = <"Nome da tarefa adicional realizada durante o procedimento."> > ["at0053"] = < text = <"Tree(en)"> description = <"@ internal @"> > ["at0054"] = < text = <"Identificador do solicitante do pedido"> description = <"ID local atribuído ao pedido pela profissional ou organização de saúde solicitante do serviço."> > ["at0055"] = < text = <"Solicitante"> description = <"Detalhes sobre o profissional ou organização de saúde que solicitou o serviço."> > ["at0056"] = < text = <"Identificador do destinatário do pedido"> description = <"O ID atribuído ao pedido pelo profissional ou organização de saúde que está recebendo a requisição do serviço. Isto também é referenciado como o Identificador de Preenchimento do Pedido."> > ["at0057"] = < text = <"Destinatário"> description = <"Detalhes sobre o profissional ou organização de saúde que recebeu o requerimento para o serviço."> > ["at0058"] = < text = <"Emergência?"> description = <"Este procedimento foi realizado como urgência? Verdadeiro se Sim."> > > > ["ar-sy"] = < items = < ["at0000"] = < text = <"الإجراء الطبي الذي تم فعله"> description = <"نشاط سريري تم تنفيذه لأغراض تشخيصية أو علاجية."> > ["at0001"] = < text = <"Tree"> description = <"@ internal @"> > ["at0002"] = < text = <"الإجراء الطبي"> description = <"اسم الإجراء الطبي"> > ["at0003"] = < text = <"تفاصيل الإجراء الطبي"> description = <"مركب تفصيلي يصف الإجراء الطبي الذي تم تنفيذه, بما في ذلك التحضير و تفاصيل حول الطريقة و المعدات/الأجهزة التي تم استخدامها"> > ["at0004"] = < text = <"لم ينجح الإجراء الطبي"> description = <"هل كان الإجراء الطبي في المجمل غير ناجحا - الإجابة بكلمة صحيح تعني أنه لم يكن ناجحا"> > ["at0005"] = < text = <"تعليق"> description = <"تعليقات حول الإجراء الطبي"> > ["at0006"] = < text = <"المضاعفات"> description = <"تفاصيل حول أية مضاعفات تنتج عن تنفيذ الإجراء الطبي"> > ["at0013"] = < text = <"الوسائط المتعددة"> description = <"تمثيل الوسائط المتعددة للإجراء الطبي, بما في ذلك الصور"> > ["at0014"] = < text = <"سبب/أسباب الإجراء الطبي"> description = <"السبب أو الداعي إلى تنفيذ الإجراء الطبي"> > ["at0015"] = < text = <"واقعة غير مخطط لها"> description = <"واقعة غير مخطط لها تسبق أو تتعلق بالإجراء الطبي, و التي قد تؤثر على تنفيذه, مثلا إذا قامالمريض بإزالة القُنَيَّة بنفسه."> > ["at0018"] = < text = <"المحاولات الفاشلة"> description = <"عدد المحاولات الفاشلة لتنفيذ الإجراء الطبي"> > ["at0030"] = < text = <"الوظائف/المهمات الإضافية"> description = <"لتسجيل المعلومات حول الأنشطة غير المخطط لها أو غير المتوقعة التي تم الاحتياج إلى فعلها في أثناء الإجراء الطبي. يتم تسجيل اسم المهمة/الوظيفة و وصفها في ذاخل هذا النموذج, و لكن ينبغي تسجيل التفاصيل في نماذج مخصصة مرتبطة بهذا النموذج من نوع نماذج التعليمات أو الفعل."> > ["at0031"] = < text = <"وصف المهمة/الوظيفة"> description = <"وصف الوظيفة/المهمة الإضافية التي تم إجراؤها في أثناء تنفيذ الإجراء الطبي"> > ["at0032"] = < text = <"تسجيل المهمة/الوظيفة الإضافية"> description = <"رابط يؤدي إلى سجل تفصيلي حول المهمة/الوظيفة الإضافية"> > ["at0034"] = < text = <"تم البدء في الطلب"> description = <"تم البدء في طلب الإجراء الطبي"> > ["at0035"] = < text = <"تم إرسال الطلب"> description = <"تم إرسال طلب الإجراء الطبي"> > ["at0036"] = < text = <"تم تحديد موعد الإجراء الطبي"> description = <"تم تحديد موعد تنفيذ الإجراء الطبي"> > ["at0038"] = < text = <"تم تأجيل الطلب"> description = <"تم تأجيل طلب الإجراء الطبي"> > ["at0039"] = < text = <"تم إلغاء الطلب"> description = <"تم إلغاء طلب الإجراء الطبي"> > ["at0040"] = < text = <"تم تعليق الإجراء الطبي"> description = <"تم تعليق الإجراء الطبي"> > ["at0041"] = < text = <"تم إنهاء الإجراء الطبي فجأة"> description = <"تم إنهاء الإجراء الطبي فجأة"> > ["at0043"] = < text = <"اكتمل"> description = <"تم إكمال الإجراء الطبي"> > ["at0044"] = < text = <"تمت كتابة التقرير"> description = <"تم كتابة تقرير الإجراء الطبي"> > ["at0045"] = < text = <"تم التصديق على/توثيق التقرير"> description = <"تم التصديق على/توثيق تقرير الإجراء الطبي"> > ["at0046"] = < text = <"تم إرسال التقرير"> description = <"تم توزيع تقرير الإجراء الطبي"> > ["at0047"] = < text = <"دائر - يحدث حاليا"> description = <"يتم حاليا تنفيذ الإجراء الطبي"> > ["at0048"] = < text = <"الناتج"> description = <"ناتج الإجراء الطبي الذي تم تنفيذه"> > ["at0049"] = < text = <"الوصف"> description = <"وصف برواية حول الإجراء الطبي الذي تم تنفيذه"> > ["at0050"] = < text = <"تفاصيل المكان التشريحي"> description = <"تفاصيل حول المكان التشريحي المتعلق بالإجراء الطبي"> > ["at0051"] = < text = <"الطريقة/التقنية"> description = <"تعريف للطريقة أو التقنية المحددة المستخدمة في تنفيذ الإجراء الطبي"> > ["at0052"] = < text = <"المهمة/الوظيفة"> description = <"اسم الوظائف/المهام الإضافية التي يتم إجراؤها في أثناء تنفيذ الإجراء الطبي"> > ["at0053"] = < text = <"Tree"> description = <"@ internal @"> > ["at0054"] = < text = <"عنصر معرِّف فريد بواسطة طالب الاختبار"> description = <"العنصر التعريفي الفريد المحلي الذي يتم إعطاؤه للأمر بالاختبار بواسطة مقدم الخدمة الصحية أو المؤسسة التي تطلب الخدمة."> > ["at0055"] = < text = <"الطالب"> description = <"تفاصيل حول مقدم الخدمة الصحية أو المؤسسة التي تطلب الخدمة"> > ["at0056"] = < text = <"عنصر معرِّف فريد بواسطة مستقبِل الطلب"> description = <"العنصر التعريفي الذي يتم إعطاؤه للأمر بالاختبار بواسطة مقدم الخدمة الصحية أو المؤسسة التي تستقبل طلب الخدمة. و يُعرَف أيضا بالعنصر معرِّف فريد بواسطة منفذ الاختبار"> > ["at0057"] = < text = <"المستقبِل"> description = <"تفاصيل حول مقدم الخدمة الصحية أو المؤسسة التي تستقبل طلب الخدمة."> > ["at0058"] = < text = <"حالة طارئة"> description = <"هل كان الإجراء الذي تم تنفيذه حالة طارئة - الإجابة بصحيح تعني أنه كان بالفعل بسبب حالة طارئة"> > > > ["ru"] = < items = < ["at0000"] = < text = <"Выполняемая процедура"> description = <"Клинические действия, предпринимаемые с лечебными или диагностическими целями"> > ["at0001"] = < text = <"*Tree(en)"> description = <"*@ internal @(en)"> > ["at0002"] = < text = <"Название процедуры"> description = <"Название процедуры"> > ["at0003"] = < text = <"Подробности процедуры"> description = <"Детальное структурированное описание выполнения, включая подготовку, используемое оборудование, подробности метода"> > ["at0004"] = < text = <"Неудачная процедура"> description = <"Ответ \\\"да\\\" если процедура неудачн"> > ["at0005"] = < text = <"Комментарии"> description = <"Комментарии к процедуре"> > ["at0006"] = < text = <"Осложнения"> description = <"Подробности возникших осложнений, вызванных процедурой"> > ["at0013"] = < text = <"Мультимедия"> description = <"Мультимедийное представление процедуры, включая изображения"> > ["at0014"] = < text = <"Показания для процедуры"> description = <"Показания для процедуры"> > ["at0015"] = < text = <"Незапланированное событие"> description = <"Незапланированные события, произошедшие до или во время процедуры, способные повлиять на ее выполнение (например, больной вытащил канюлю)"> > ["at0018"] = < text = <"Неудачные попытки"> description = <"Число неудачных попыток выполнения процедуры"> > ["at0030"] = < text = <"Дополнительные задачи"> description = <"Информация о незапланированных или неожиданных действиях, потребовавшихся в ходе выполнения процедуры. В пределах данного архетипа записывается название работ и их описание, подробности размещаются в отдельных архетипах типа ДЕЙСТВИЕ или ПРЕДПИСАНИЕ"> > ["at0031"] = < text = <"Описание задачи"> description = <"Описание задачи, возникшей и потребовавшей решения в ходе процедуры"> > ["at0032"] = < text = <"Ссылка"> description = <"Ссылка на подробное описание дополнительной задачи"> > ["at0034"] = < text = <"Процедура заказана"> description = <"Начало заказа процедуры"> > ["at0035"] = < text = <"Заявка отправлена"> description = <"Отправлена заявка на выполнение процедуры"> > ["at0036"] = < text = <"Включена в расписание"> description = <"Процедура включена в расписание"> > ["at0038"] = < text = <"Заявка задержана"> description = <"Заявка на процедуру задержана"> > ["at0039"] = < text = <"Заявка отменена"> description = <"Заявка отменена"> > ["at0040"] = < text = <"Отложена"> description = <"Процедура отложена"> > ["at0041"] = < text = <"Процедура прервана"> description = <"Процедура прервана"> > ["at0043"] = < text = <"Выполнена"> description = <"Процедура выполнена"> > ["at0044"] = < text = <"Ппротокол подписан"> description = <"Протокол процедуры подписан"> > ["at0045"] = < text = <"Протокол проверен"> description = <"Протокол проверен"> > ["at0046"] = < text = <"Протокол отправлен"> description = <"Протокол отправлен"> > ["at0047"] = < text = <"Выполняется"> description = <"Процедура в процессе выполнения"> > ["at0048"] = < text = <"Результат"> description = <"Результат проведенной процедуры"> > ["at0049"] = < text = <"Описание"> description = <"Текстовое описание выполнения процедуры"> > ["at0050"] = < text = <"Подробности анатомической области"> description = <"Подробности анатомической области"> > ["at0051"] = < text = <"Метод /техника"> description = <"Определение конкретного метода, использованного при выполнении процедуры"> > ["at0052"] = < text = <"Задача"> description = <"Название дополнительной задачи, решение которой потребовалось в ходе процедуры"> > ["at0053"] = < text = <"*Tree(en)"> description = <"*@ internal @(en)"> > ["at0054"] = < text = <"Указатель на заказ"> description = <"Локальный идентификатор заказа от организации, запросившей услугу"> > ["at0055"] = < text = <"Заказчик"> description = <"Подробности о заказчике (организации), запросившей услугу"> > ["at0056"] = < text = <"идентификатор получателя заказа"> description = <"Идентификатор, присвоенный заказу орагнизацией, получившей заявку. Также называется \\\"Идентифакатор полученного заказа\\"> > ["at0057"] = < text = <"Исполнитель"> description = <"Подробные сведение об организации, получившей заявку на выполнение процедуры"> > ["at0058"] = < text = <"Неотложность"> description = <"Была ли процедура выполнена по неотложным показаниям? Да, если это так"> > > > > ``` Report Procedure (openEhr Archetype) ```Archetype archetype (adl_version=1.4) openEHR-EHR-COMPOSITION.report-procedure.v1 specialise openEHR-EHR-COMPOSITION.report.v1 concept [at0000.1] -- Procedure Report language original_language = <[ISO_639-1::en]> description original_author = < ["name"] = <"Heather Leslie"> ["organisation"] = <"Ocean Informatics"> ["email"] = <"heather.leslie@oceaninformatics.com"> ["date"] = <"2012-12-10"> > details = < ["en"] = < language = <[ISO_639-1::en]> purpose = <"Generic container archetype to carry information about a procedure or operation performed."> use = <"Use as a generic procedure-related archetype to carry information about any procedure or operation performed. Common examples are: any procedure carried out as a stand-alone activity and not part of a consultation, such as a lumbar puncture or interventional radiology procedure; Endoscopy Report; through to a complete surgical operation report. The Context component contains an optional unnamed slot that can be used to: - add optional content during templating to support a use-case specific requirements; - add EHR model demographic archetypes representing participating parties. While this may not be desired at implementation, this can be useful to demonstrate how demographics may be represented in an implementation ie as a support to clinical content requirements gathering or template review. The Sections component has been deliberately left unconstrained to maximise re-use of this archetype."> keywords = <"report", ...> misuse = <""> copyright = <"© openEHR Foundation"> > > lifecycle_state = <"AuthorDraft"> other_contributors = <"Heath Frankel, Ocean Informatics, Australia", "Sam Heard, Ocean Informatics, Australia", "Sistine Barretto-Daniels, Ocean Informatics, Australia", "Hugh Leslie, Ocean Informatics, Australia", "Ian McNicoll, Ocean Informatics, Australia"> other_details = < ["current_contact"] = <"Heather Leslie, Ocean Informatics, heather.leslie@oceaninformatics.com"> ["MD5-CAM-1.0.1"] = <"A158BB6DE8284F674B65C6D6C0BC5345"> > definition COMPOSITION[at0000.1] matches { -- Procedure Report category matches { DV_CODED_TEXT matches { defining_code matches {[openehr::433]} } } context matches { EVENT_CONTEXT matches { other_context matches { ITEM_TREE[at0001] matches { -- Tree items cardinality matches {0..*; unordered} matches { ELEMENT[at0002] occurrences matches {0..1} matches { -- Report ID value matches { DV_TEXT matches {*} } } ELEMENT[at0005] occurrences matches {0..1} matches { -- Status value matches { DV_TEXT matches {*} } } allow_archetype CLUSTER occurrences matches {0..*} matches { include archetype_id/value matches {/.*/} } } } } } } } ontology term_definitions = < ["en"] = < items = < ["at0000"] = < text = <"Report"> description = <"Document to communicate information to others, commonly in response to a request from another party."> > ["at0000.1"] = < text = <"Procedure Report"> description = <"Document to communicate information to others about any stand-alone procedure or operation performed."> > ["at0001"] = < text = <"Tree"> description = <"@ internal @"> > ["at0002"] = < text = <"Report ID"> description = <"Identification information about the report."> > ["at0005"] = < text = <"Status"> description = <"The status of the entire report. Note: This is not the status of any of the report components."> > > > > ```
semr/specs
patient-charting/manage-procedure-instruction/create-procedure-instruction.md
Markdown
agpl-3.0
42,637
[ 30522, 1001, 1001, 1001, 1001, 1001, 2224, 2553, 8909, 1024, 15384, 1011, 27019, 12740, 1001, 1001, 1001, 1001, 1001, 2224, 2553, 2171, 1024, 3443, 7709, 7899, 1008, 1008, 2504, 1024, 1008, 1008, 5310, 2504, 3125, 1008, 1008, 3078, 5889, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * * * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */ package java.io; /** * This abstract class is the superclass of all classes representing * an input stream of bytes. * * <p> Applications that need to define a subclass of <code>InputStream</code> * must always provide a method that returns the next byte of input. * * @version 12/17/01 (CLDC 1.1) * @see java.io.ByteArrayInputStream * @see java.io.DataInputStream * @see java.io.InputStream#read() * @see java.io.OutputStream * @since JDK1.0, CLDC 1.0 */ public abstract class InputStream { /** * Reads the next byte of data from the input stream. The value byte is * returned as an <code>int</code> in the range <code>0</code> to * <code>255</code>. If no byte is available because the end of the stream * has been reached, the value <code>-1</code> is returned. This method * blocks until input data is available, the end of the stream is detected, * or an exception is thrown. * * <p> A subclass must provide an implementation of this method. * * @return the next byte of data, or <code>-1</code> if the end of the * stream is reached. * @exception IOException if an I/O error occurs. */ public abstract int read() throws IOException; /** * Reads some number of bytes from the input stream and stores them into * the buffer array <code>b</code>. The number of bytes actually read is * returned as an integer. This method blocks until input data is * available, end of file is detected, or an exception is thrown. * * <p> If <code>b</code> is <code>null</code>, a * <code>NullPointerException</code> is thrown. If the length of * <code>b</code> is zero, then no bytes are read and <code>0</code> is * returned; otherwise, there is an attempt to read at least one byte. If * no byte is available because the stream is at end of file, the value * <code>-1</code> is returned; otherwise, at least one byte is read and * stored into <code>b</code>. * * <p> The first byte read is stored into element <code>b[0]</code>, the * next one into <code>b[1]</code>, and so on. The number of bytes read is, * at most, equal to the length of <code>b</code>. Let <i>k</i> be the * number of bytes actually read; these bytes will be stored in elements * <code>b[0]</code> through <code>b[</code><i>k</i><code>-1]</code>, * leaving elements <code>b[</code><i>k</i><code>]</code> through * <code>b[b.length-1]</code> unaffected. * * <p> If the first byte cannot be read for any reason other than end of * file, then an <code>IOException</code> is thrown. In particular, an * <code>IOException</code> is thrown if the input stream has been closed. * * <p> The <code>read(b)</code> method for class <code>InputStream</code> * has the same effect as: <pre><code> read(b, 0, b.length) </code></pre> * * @param b the buffer into which the data is read. * @return the total number of bytes read into the buffer, or * <code>-1</code> is there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.InputStream#read(byte[], int, int) */ public int read(byte b[]) throws IOException { return read(b, 0, b.length); } /** * Reads up to <code>len</code> bytes of data from the input stream into * an array of bytes. An attempt is made to read as many as * <code>len</code> bytes, but a smaller number may be read, possibly * zero. The number of bytes actually read is returned as an integer. * * <p> This method blocks until input data is available, end of file is * detected, or an exception is thrown. * * <p> If <code>b</code> is <code>null</code>, a * <code>NullPointerException</code> is thrown. * * <p> If <code>off</code> is negative, or <code>len</code> is negative, or * <code>off+len</code> is greater than the length of the array * <code>b</code>, then an <code>IndexOutOfBoundsException</code> is * thrown. * * <p> If <code>len</code> is zero, then no bytes are read and * <code>0</code> is returned; otherwise, there is an attempt to read at * least one byte. If no byte is available because the stream is at end of * file, the value <code>-1</code> is returned; otherwise, at least one * byte is read and stored into <code>b</code>. * * <p> The first byte read is stored into element <code>b[off]</code>, the * next one into <code>b[off+1]</code>, and so on. The number of bytes read * is, at most, equal to <code>len</code>. Let <i>k</i> be the number of * bytes actually read; these bytes will be stored in elements * <code>b[off]</code> through <code>b[off+</code><i>k</i><code>-1]</code>, * leaving elements <code>b[off+</code><i>k</i><code>]</code> through * <code>b[off+len-1]</code> unaffected. * * <p> In every case, elements <code>b[0]</code> through * <code>b[off]</code> and elements <code>b[off+len]</code> through * <code>b[b.length-1]</code> are unaffected. * * <p> If the first byte cannot be read for any reason other than end of * file, then an <code>IOException</code> is thrown. In particular, an * <code>IOException</code> is thrown if the input stream has been closed. * * <p> The <code>read(b,</code> <code>off,</code> <code>len)</code> method * for class <code>InputStream</code> simply calls the method * <code>read()</code> repeatedly. If the first such call results in an * <code>IOException</code>, that exception is returned from the call to * the <code>read(b,</code> <code>off,</code> <code>len)</code> method. If * any subsequent call to <code>read()</code> results in a * <code>IOException</code>, the exception is caught and treated as if it * were end of file; the bytes read up to that point are stored into * <code>b</code> and the number of bytes read before the exception * occurred is returned. Subclasses are encouraged to provide a more * efficient implementation of this method. * * @param b the buffer into which the data is read. * @param off the start offset in array <code>b</code> * at which the data is written. * @param len the maximum number of bytes to read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.InputStream#read() */ public int read(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c = read(); if (c == -1) { return -1; } b[off] = (byte)c; int i = 1; try { for (; i < len ; i++) { c = read(); if (c == -1) { break; } if (b != null) { b[off + i] = (byte)c; } } } catch (IOException ee) { } return i; } /** * Skips over and discards <code>n</code> bytes of data from this input * stream. The <code>skip</code> method may, for a variety of reasons, end * up skipping over some smaller number of bytes, possibly <code>0</code>. * This may result from any of a number of conditions; reaching end of file * before <code>n</code> bytes have been skipped is only one possibility. * The actual number of bytes skipped is returned. If <code>n</code> is * negative, no bytes are skipped. * * <p> The <code>skip</code> method of <code>InputStream</code> creates a * byte array and then repeatedly reads into it until <code>n</code> bytes * have been read or the end of the stream has been reached. Subclasses are * encouraged to provide a more efficient implementation of this method. * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. * @exception IOException if an I/O error occurs. */ public long skip(long n) throws IOException { long m = n; while (m > 0) { if (read() < 0) { break; } --m; } return n-m; } /** * Returns the number of bytes that can be read (or skipped over) from * this input stream without blocking by the next caller of a method for * this input stream. The next caller might be the same thread or * another thread. * * <p> The <code>available</code> method for class <code>InputStream</code> * always returns <code>0</code>. * * <p> This method should be overridden by subclasses. * * @return the number of bytes that can be read from this input stream * without blocking. * @exception IOException if an I/O error occurs. */ public int available() throws IOException { return 0; } /** * Closes this input stream and releases any system resources associated * with the stream. * * <p> The <code>close</code> method of <code>InputStream</code> does * nothing. * * @exception IOException if an I/O error occurs. */ public void close() throws IOException {} /** * Marks the current position in this input stream. A subsequent call to * the <code>reset</code> method repositions this stream at the last marked * position so that subsequent reads re-read the same bytes. * * <p> The <code>readlimit</code> arguments tells this input stream to * allow that many bytes to be read before the mark position gets * invalidated. * * <p> The general contract of <code>mark</code> is that, if the method * <code>markSupported</code> returns <code>true</code>, the stream somehow * remembers all the bytes read after the call to <code>mark</code> and * stands ready to supply those same bytes again if and whenever the method * <code>reset</code> is called. However, the stream is not required to * remember any data at all if more than <code>readlimit</code> bytes are * read from the stream before <code>reset</code> is called. * * <p> The <code>mark</code> method of <code>InputStream</code> does * nothing. * * @param readlimit the maximum limit of bytes that can be read before * the mark position becomes invalid. * @see java.io.InputStream#reset() */ public synchronized void mark(int readlimit) {} /** * Repositions this stream to the position at the time the * <code>mark</code> method was last called on this input stream. * * <p> The general contract of <code>reset</code> is: * * <p><ul> * * <li> If the method <code>markSupported</code> returns * <code>true</code>, then: * * <ul><li> If the method <code>mark</code> has not been called since * the stream was created, or the number of bytes read from the stream * since <code>mark</code> was last called is larger than the argument * to <code>mark</code> at that last call, then an * <code>IOException</code> might be thrown. * * <li> If such an <code>IOException</code> is not thrown, then the * stream is reset to a state such that all the bytes read since the * most recent call to <code>mark</code> (or since the start of the * file, if <code>mark</code> has not been called) will be resupplied * to subsequent callers of the <code>read</code> method, followed by * any bytes that otherwise would have been the next input data as of * the time of the call to <code>reset</code>. </ul> * * <li> If the method <code>markSupported</code> returns * <code>false</code>, then: * * <ul><li> The call to <code>reset</code> may throw an * <code>IOException</code>. * * <li> If an <code>IOException</code> is not thrown, then the stream * is reset to a fixed state that depends on the particular type of the * input stream and how it was created. The bytes that will be supplied * to subsequent callers of the <code>read</code> method depend on the * particular type of the input stream. </ul></ul> * * <p> The method <code>reset</code> for class <code>InputStream</code> * does nothing and always throws an <code>IOException</code>. * * @exception IOException if this stream has not been marked or if the * mark has been invalidated. * @see java.io.InputStream#mark(int) * @see java.io.IOException */ public synchronized void reset() throws IOException { throw new IOException( /* #ifdef VERBOSE_EXCEPTIONS */ /// skipped "mark/reset not supported" /* #endif */ ); } /** * Tests if this input stream supports the <code>mark</code> and * <code>reset</code> methods. The <code>markSupported</code> method of * <code>InputStream</code> returns <code>false</code>. * * @return <code>true</code> if this true type supports the mark and reset * method; <code>false</code> otherwise. * @see java.io.InputStream#mark(int) * @see java.io.InputStream#reset() */ public boolean markSupported() { return false; } }
tommythorn/yari
shared/cacao-related/phoneme_feature/cldc/src/javaapi/cldc1.1/java/io/InputStream.java
Java
gpl-2.0
15,242
[ 30522, 1013, 1008, 1008, 1008, 1008, 9385, 2901, 1011, 2294, 3103, 12702, 29390, 1010, 4297, 1012, 2035, 2916, 9235, 1012, 1008, 30524, 5371, 20346, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class WelcomeController < InheritedResources::Base def index @map = map end private def map MapLayers::JsExtension::MapBuilder.new("map") do |builder, page| # OpenStreetMap layer page << builder.map.add_layer(MapLayers::OpenLayers::OSM_MAPNIK) # Add a button to hide/show layers page << builder.map.add_control(MapLayers::OpenLayers::Control::LayerSwitcher.new) # Add mouse coordinates page << builder.map.add_control(MapLayers::OpenLayers::Control::MousePosition.new) # Add a vector layer to read from kml url page << builder.add_vector_layer('stop_areas', "/stop_areas.kml", :format => :kml) # Initialize select, point, path, polygon and drag control for features # you may want to handle event on only one layer #page << builder.map_handler.initialize_controls('map_controls', 'pikts') # if you need to handle events on multiple layers, add all theses layers to the initializer # drag events and draw (point, path, polygon) events only works on the first layer, in this case 'pikts' page << builder.map_handler.initialize_controls('map_controls', ['stop_areas']) # Switch control mode, 'select' display popup on feature # available mode are : # - select, to display popup # - point, to create points on map # - path, to draw path on map # - polygon, to draw polygons on map # - drag, to move features # - none, to disable all controls page << builder.map_handler.toggle_control('map_controls', 'select') page << builder.map.zoom_to_max_extent() end end end
maplayers/map_layers_example_app
app/controllers/welcome_controller.rb
Ruby
agpl-3.0
1,661
[ 30522, 2465, 6160, 8663, 13181, 10820, 1026, 7900, 6072, 8162, 9623, 1024, 1024, 2918, 13366, 5950, 1030, 4949, 1027, 4949, 2203, 2797, 13366, 4949, 4949, 24314, 2015, 1024, 1024, 1046, 3366, 18413, 6132, 3258, 1024, 1024, 4949, 8569, 23891...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.kitchen_ehhd.Models; /** * Created by yisen_000 on 2015-09-19. */ public class DrawerItem { private String name; private int drawerNum; public DrawerItem(String name, int drawerNum) { this.name = name; this.drawerNum = drawerNum; } public String getName() { return name; } public int getDrawerNum() { return drawerNum; } }
vishalkuo/Kitchen-Ehhd
Android/Kitchen-Ehhd/app/src/main/java/com/kitchen_ehhd/Models/DrawerItem.java
Java
mit
405
[ 30522, 7427, 4012, 1012, 3829, 1035, 15501, 14945, 1012, 4275, 1025, 1013, 1008, 1008, 1008, 2580, 2011, 12316, 5054, 1035, 2199, 2006, 2325, 1011, 5641, 1011, 2539, 1012, 1008, 1013, 2270, 2465, 13065, 4221, 2213, 1063, 2797, 5164, 2171, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qgeometryrenderer.cpp --> <title>GeometryRenderer QML Type | Qt 3D 5.7</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> window.onload = function(){document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");}; </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td ><a href="../qtdoc/supported-platforms-and-configurations.html#qt-5-7">Qt 5.7</a></td><td ><a href="qt3d-index.html">Qt 3D</a></td><td ><a href="qt3d-core-qmlmodule.html">QML Types</a></td><td >GeometryRenderer QML Type</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.7.0 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">GeometryRenderer QML Type</h1> <span class="subtitle"></span> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import Qt3D.Render 2.0</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Instantiates:</td><td class="memItemRight bottomAlign"> <a href="qml-qt3d-render-geometryrenderer.html"><a href="qt3drender-qgeometryrenderer.html">QGeometryRenderer</a></td></tr></table></div><ul> <li><a href="qml-qt3d-render-geometryrenderer-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#firstInstance-prop">firstInstance</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#firstVertex-prop">firstVertex</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#geometry-prop">geometry</a></b></b> : Geometry</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#indexOffset-prop">indexOffset</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#instanceCount-prop">instanceCount</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#primitiveRestart-prop">primitiveRestart</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#primitiveType-prop">primitiveType</a></b></b> : QGeometryRenderer::PrimitiveType</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#restartIndex-prop">restartIndex</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#vertexCount-prop">vertexCount</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-qt3d-render-geometryrenderer.html#verticesPerPatch-prop">verticesPerPatch</a></b></b> : int</li> </ul> <!-- $$$GeometryRenderer-description --> <a name="details"></a> <h2 id="details">Detailed Description</h2> <!-- @@@GeometryRenderer --> <h2>Property Documentation</h2> <!-- $$$firstInstance --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="firstInstance-prop"> <td class="tblQmlPropNode"><p> <a name="firstInstance-prop"></a><span class="name">firstInstance</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the first vertex.</p> </div></div><!-- @@@firstInstance --> <br/> <!-- $$$firstVertex --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="firstVertex-prop"> <td class="tblQmlPropNode"><p> <a name="firstVertex-prop"></a><span class="name">firstVertex</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the base instance.</p> </div></div><!-- @@@firstVertex --> <br/> <!-- $$$geometry --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="geometry-prop"> <td class="tblQmlPropNode"><p> <a name="geometry-prop"></a><span class="name">geometry</span> : <span class="type"><a href="qml-qt3d-render-geometry.html">Geometry</a></span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the geometry.</p> </div></div><!-- @@@geometry --> <br/> <!-- $$$indexOffset --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="indexOffset-prop"> <td class="tblQmlPropNode"><p> <a name="indexOffset-prop"></a><span class="name">indexOffset</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the base vertex.</p> </div></div><!-- @@@indexOffset --> <br/> <!-- $$$instanceCount --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="instanceCount-prop"> <td class="tblQmlPropNode"><p> <a name="instanceCount-prop"></a><span class="name">instanceCount</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the instance count.</p> </div></div><!-- @@@instanceCount --> <br/> <!-- $$$primitiveRestart --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="primitiveRestart-prop"> <td class="tblQmlPropNode"><p> <a name="primitiveRestart-prop"></a><span class="name">primitiveRestart</span> : <span class="type">bool</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the primitive restart flag.</p> </div></div><!-- @@@primitiveRestart --> <br/> <!-- $$$primitiveType --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="primitiveType-prop"> <td class="tblQmlPropNode"><p> <a name="primitiveType-prop"></a><span class="name">primitiveType</span> : <span class="type">QGeometryRenderer::PrimitiveType</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the primitive type.</p> </div></div><!-- @@@primitiveType --> <br/> <!-- $$$restartIndex --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="restartIndex-prop"> <td class="tblQmlPropNode"><p> <a name="restartIndex-prop"></a><span class="name">restartIndex</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the restart index.</p> </div></div><!-- @@@restartIndex --> <br/> <!-- $$$vertexCount --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="vertexCount-prop"> <td class="tblQmlPropNode"><p> <a name="vertexCount-prop"></a><span class="name">vertexCount</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds the vertex count.</p> </div></div><!-- @@@vertexCount --> <br/> <!-- $$$verticesPerPatch --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="verticesPerPatch-prop"> <td class="tblQmlPropNode"><p> <a name="verticesPerPatch-prop"></a><span class="name">verticesPerPatch</span> : <span class="type">int</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Holds vertices per patch.</p> </div></div><!-- @@@verticesPerPatch --> <br/> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">&copy;</acronym> 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>
angeloprudentino/QtNets
Doc/qt3d/qml-qt3d-render-geometryrenderer.html
HTML
gpl-3.0
8,642
[ 30522, 1026, 1029, 20950, 2544, 1027, 1000, 1015, 1012, 1014, 1000, 17181, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1029, 1028, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using System.Collections.Generic; using EspaceClient.BackOffice.Domaine.Results; using EspaceClient.BackOffice.Silverlight.Business.Depots; using EspaceClient.BackOffice.Silverlight.Business.Interfaces; using EspaceClient.BackOffice.Silverlight.Infrastructure.Services; using EspaceClient.FrontOffice.Domaine; using nRoute.Components.Composition; using EspaceClient.BackOffice.Silverlight.Infrastructure.ServicePieceJointe; namespace EspaceClient.BackOffice.Silverlight.Data.Depots { /// <summary> /// Dépôt des pieces jointes /// </summary> [MapResource(typeof(IDepotPieceJointe), InstanceLifetime.Singleton)] public class DepotPieceJointe : IDepotPieceJointe { private readonly IServiceClientFactory _services; private readonly IApplicationContext _applicationContext; /// <summary> /// Initialise une nouvelle instance du dépôt. /// </summary> /// <param name="services">Fournisseur de services.</param> /// <param name="scheduler">Scheduler de tâches.</param> [ResolveConstructor] public DepotPieceJointe(IApplicationContext applicationContext, IServiceClientFactory services) { _applicationContext = applicationContext; _services = services; } public void UploadPieceJointeStarted(PieceJointeDto pieceJointe, Action<PieceJointeDto> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<UploadPieceJointeStartedCompletedEventArgs>( s => s.UploadPieceJointeStartedAsync(_applicationContext.Context, pieceJointe), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void UploadPieceJointeFinished(PieceJointeDto pieceJointe, Action<PieceJointeResult> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<UploadPieceJointeFinishedCompletedEventArgs>( s => s.UploadPieceJointeFinishedAsync(_applicationContext.Context, pieceJointe), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void AddLink(PieceJointeDto pieceJointe, Action<PieceJointeResult> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<AddLinkCompletedEventArgs>( s => s.AddLinkAsync(_applicationContext.Context, pieceJointe), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void UploadPieceJointe(PieceJointeDto pieceJointe, byte[] data, long part, Action<PieceJointeDto> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<UploadPieceJointeCompletedEventArgs>( s => s.UploadPieceJointeAsync(_applicationContext.Context, pieceJointe, data, part), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void GetPieceJointes(long vueId, long idFonctionnel, Action<IEnumerable<PieceJointeResult>> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<GetPieceJointesCompletedEventArgs>( s => s.GetPieceJointesAsync(_applicationContext.Context, vueId, idFonctionnel), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void GetPieceJointesByIdStarted(long pieceJointeId, Action<PieceJointeDto> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<GetPieceJointeByIdStartedCompletedEventArgs>( s => s.GetPieceJointeByIdStartedAsync(_applicationContext.Context, pieceJointeId), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void GetPieceJointesById(long pieceJointeId, long part, Action<byte[]> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<GetPieceJointeByIdCompletedEventArgs>( s => s.GetPieceJointeByIdAsync(_applicationContext.Context, pieceJointeId, part), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } public void DeletePieceJointe(long pieceJointeId, Action<bool> callback, Action<Exception> error) { _services.ServicePieceJointe.Call<DeletePieceJointeCompletedEventArgs>( s => s.DeletePieceJointeAsync(_applicationContext.Context, pieceJointeId), r => { if (r.Error != null) error(r.Error); else callback(r.Result); }); } } }
apo-j/Projects_Working
EC/espace-client-dot-net/EspaceClient.BackOffice.Silverlight.Data/Depots/DepotPieceJointe.cs
C#
mit
5,620
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 9686, 15327, 20464, 11638, 1012, 2067, 7245, 6610, 1012, 5884, 2063, 1012, 3463, 1025, 2478, 9686, 15327, 20464, 11638, 1012, 2067, 7245, 6610, 1012, 3165, 7138, 1012...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #include <aws/core/client/AWSError.h> #include <aws/redshift/RedshiftErrorMarshaller.h> #include <aws/redshift/RedshiftErrors.h> using namespace Aws::Client; using namespace Aws::Redshift; AWSError<CoreErrors> RedshiftErrorMarshaller::FindErrorByName(const char* errorName) const { AWSError<CoreErrors> error = RedshiftErrorMapper::GetErrorForName(errorName); if(error.GetErrorType() != CoreErrors::UNKNOWN) { return error; } return AWSErrorMarshaller::FindErrorByName(errorName); }
ambasta/aws-sdk-cpp
aws-cpp-sdk-redshift/source/RedshiftErrorMarshaller.cpp
C++
apache-2.0
1,074
[ 30522, 1013, 1008, 1008, 9385, 2230, 1011, 2355, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.jsoniter.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface JsonIgnore { boolean ignoreDecoding() default true; boolean ignoreEncoding() default true; }
json-iterator/java
src/main/java/com/jsoniter/annotation/JsonIgnore.java
Java
mit
452
[ 30522, 7427, 4012, 1012, 1046, 3385, 21646, 1012, 5754, 17287, 3508, 1025, 12324, 9262, 1012, 11374, 1012, 5754, 17287, 3508, 1012, 5783, 13874, 1025, 12324, 9262, 1012, 11374, 1012, 5754, 17287, 3508, 1012, 20125, 1025, 12324, 9262, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.flink.table.planner.delegation; import org.apache.flink.annotation.Internal; import org.apache.flink.table.api.EnvironmentSettings; import org.apache.flink.table.api.TableConfig; import org.apache.flink.table.catalog.CatalogManager; import org.apache.flink.table.catalog.FunctionCatalog; import org.apache.flink.table.delegation.Executor; import org.apache.flink.table.delegation.Planner; import org.apache.flink.table.delegation.PlannerFactory; import org.apache.flink.table.descriptors.DescriptorProperties; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; /** Factory to construct a {@link BatchPlanner} or {@link StreamPlanner}. */ @Internal public final class BlinkPlannerFactory implements PlannerFactory { @Override public Planner create( Map<String, String> properties, Executor executor, TableConfig tableConfig, FunctionCatalog functionCatalog, CatalogManager catalogManager) { if (Boolean.valueOf(properties.getOrDefault(EnvironmentSettings.STREAMING_MODE, "true"))) { return new StreamPlanner(executor, tableConfig, functionCatalog, catalogManager); } else { return new BatchPlanner(executor, tableConfig, functionCatalog, catalogManager); } } @Override public Map<String, String> optionalContext() { Map<String, String> map = new HashMap<>(); map.put(EnvironmentSettings.CLASS_NAME, this.getClass().getCanonicalName()); return map; } @Override public Map<String, String> requiredContext() { DescriptorProperties properties = new DescriptorProperties(); return properties.asMap(); } @Override public List<String> supportedProperties() { return Arrays.asList(EnvironmentSettings.STREAMING_MODE, EnvironmentSettings.CLASS_NAME); } }
tillrohrmann/flink
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/delegation/BlinkPlannerFactory.java
Java
apache-2.0
2,727
[ 30522, 1013, 1008, 1008, 7000, 30524, 1008, 4953, 9385, 6095, 1012, 1996, 2004, 2546, 15943, 2023, 5371, 1008, 2000, 2017, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1008, 1000, 6105, 1000, 1007, 1025, 2017, 2089, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
(function() { 'use strict'; angular .module('app') .constant('FIREBASE_BASE_URL', 'https://word-game-d1e51.firebaseio.com'); })();
taritamas89/word-game
src/app/config/constants.js
JavaScript
mit
156
[ 30522, 1006, 3853, 1006, 1007, 1063, 1005, 2224, 9384, 1005, 1025, 16108, 1012, 11336, 1006, 1005, 10439, 1005, 1007, 1012, 5377, 1006, 1005, 2543, 15058, 1035, 2918, 1035, 24471, 2140, 1005, 1010, 1005, 16770, 1024, 1013, 1013, 2773, 1011,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package net.wrap_trap.bonten.message; public class StepOk extends Message {}
masayuki038/bon-ten
src/main/java/net/wrap_trap/bonten/message/StepOk.java
Java
mit
78
[ 30522, 7427, 5658, 1012, 10236, 1035, 8132, 1012, 14753, 6528, 1012, 4471, 1025, 2270, 2465, 3357, 6559, 8908, 4471, 1063, 1065, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php defined('_JEXEC') or die(); /** * * Description * * @package VirtueMart * @subpackage Calculation tool * @author Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: default.php 6475 2012-09-21 11:54:21Z Milbo $ */ // Check to ensure this file is included in Joomla! ?> <form action="index.php" method="post" name="adminForm" id="adminForm"> <?php AdminUIHelper::startAdminArea(); ?> <div id="filter-bar" class="btn-toolbar"> <?php echo $this->displayDefaultViewSearch() ?> </div> <div class="clearfix"> </div> <div id="results"> <?php // split to use ajax search echo $this->loadTemplate('results'); ?> </div> <?php AdminUIHelper::endAdminArea(true); ?> </form>
cuongnd/test_pro
administrator/components/com_virtuemart1/views/calc/tmpl/default.php
PHP
gpl-2.0
1,115
[ 30522, 1026, 1029, 25718, 4225, 1006, 1005, 1035, 15333, 2595, 8586, 1005, 1007, 2030, 3280, 1006, 1007, 1025, 1013, 1008, 1008, 1008, 1008, 6412, 1008, 1008, 1030, 7427, 11870, 22345, 1008, 1030, 4942, 23947, 4270, 17208, 6994, 1008, 1030,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
///<reference path="Math.ts"/> class Entity { get X(): number { return this.Position.x; } get Y(): number { return this.Position.y; } get Z(): number { return this.Position.z; } constructor(public Position: Vec3) { } }
piersh/GLander
src/Entity.ts
TypeScript
apache-2.0
233
[ 30522, 1013, 1013, 1013, 1026, 4431, 4130, 1027, 1000, 8785, 1012, 24529, 1000, 1013, 1028, 2465, 9178, 1063, 2131, 1060, 1006, 1007, 1024, 2193, 1063, 2709, 2023, 1012, 2597, 1012, 1060, 1025, 1065, 2131, 1061, 1006, 1007, 1024, 2193, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- published: true title: Landed on TinyPress layout: post --- For a long time I tried to find a simple way to write technical articles mainly for my own consumption. Hopefully TinyPress is the way to go...
aanno/aanno.github.io
_posts/2016-02-21-landed-on-tinypress.markdown
Markdown
mit
212
[ 30522, 1011, 1011, 1011, 2405, 1024, 2995, 2516, 1024, 5565, 2006, 4714, 20110, 9621, 1024, 2695, 1011, 1011, 1011, 2005, 1037, 2146, 2051, 1045, 2699, 2000, 2424, 1037, 3722, 2126, 2000, 4339, 4087, 4790, 3701, 2005, 2026, 2219, 8381, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/**上午11:13:57 * @author zhangyh2 * Person.java * TODO */ package com.darly.dlvideo.bean; /** * @author zhangyh2 Person 上午11:13:57 TODO */ public class Person { private int id; private String url; private String title; private String icon; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } }
darlyhellen/oto
DLVideo/src/com/darly/dlvideo/bean/Person.java
Java
apache-2.0
671
[ 30522, 1013, 1008, 1008, 1742, 100, 2340, 1024, 2410, 1024, 5401, 1008, 1030, 3166, 9327, 2100, 2232, 2475, 1008, 2711, 1012, 9262, 1008, 28681, 2080, 1008, 1013, 7427, 4012, 1012, 18243, 2135, 1012, 21469, 17258, 8780, 1012, 14068, 1025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * This code was generated by * \ / _ _ _| _ _ * | (_)\/(_)(_|\/| |(/_ v1.0.0 * / / */ namespace Twilio\Rest\IpMessaging\V1; use Twilio\Exceptions\TwilioException; use Twilio\InstanceContext; use Twilio\Options; use Twilio\Serialize; use Twilio\Values; use Twilio\Version; class CredentialContext extends InstanceContext { /** * Initialize the CredentialContext * * @param \Twilio\Version $version Version that contains the resource * @param string $sid The unique string that identifies the resource * @return \Twilio\Rest\IpMessaging\V1\CredentialContext */ public function __construct(Version $version, $sid) { parent::__construct($version); // Path Solution $this->solution = array('sid' => $sid, ); $this->uri = '/Credentials/' . \rawurlencode($sid) . ''; } /** * Fetch a CredentialInstance * * @return CredentialInstance Fetched CredentialInstance * @throws TwilioException When an HTTP error occurs. */ public function fetch() { $params = Values::of(array()); $payload = $this->version->fetch( 'GET', $this->uri, $params ); return new CredentialInstance($this->version, $payload, $this->solution['sid']); } /** * Update the CredentialInstance * * @param array|Options $options Optional Arguments * @return CredentialInstance Updated CredentialInstance * @throws TwilioException When an HTTP error occurs. */ public function update($options = array()) { $options = new Values($options); $data = Values::of(array( 'FriendlyName' => $options['friendlyName'], 'Certificate' => $options['certificate'], 'PrivateKey' => $options['privateKey'], 'Sandbox' => Serialize::booleanToString($options['sandbox']), 'ApiKey' => $options['apiKey'], 'Secret' => $options['secret'], )); $payload = $this->version->update( 'POST', $this->uri, array(), $data ); return new CredentialInstance($this->version, $payload, $this->solution['sid']); } /** * Deletes the CredentialInstance * * @return boolean True if delete succeeds, false otherwise * @throws TwilioException When an HTTP error occurs. */ public function delete() { return $this->version->delete('delete', $this->uri); } /** * Provide a friendly representation * * @return string Machine friendly representation */ public function __toString() { $context = array(); foreach ($this->solution as $key => $value) { $context[] = "$key=$value"; } return '[Twilio.IpMessaging.V1.CredentialContext ' . \implode(' ', $context) . ']'; } }
unaio/una
upgrade/files/12.1.0-13.0.0.A1/files/plugins/twilio/sdk/src/Twilio/Rest/IpMessaging/V1/CredentialContext.php
PHP
mit
2,928
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 2023, 3642, 2001, 7013, 2011, 1008, 1032, 1013, 1035, 1035, 1035, 1064, 1035, 1035, 1008, 1064, 1006, 1035, 1007, 1032, 1013, 1006, 1035, 1007, 1006, 1035, 1064, 1032, 1013, 1064, 1064, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf-8 -*- from django.test import TestCase from django.core.urlresolvers import reverse class TestHomePage(TestCase): def test_uses_index_template(self): response = self.client.get(reverse("home")) self.assertTemplateUsed(response, "home/index.html") def test_uses_base_template(self): response = self.client.get(reverse("home")) self.assertTemplateUsed(response, "base.html")
janusnic/dj-21v
unit_02/mysite/home/test.py
Python
mit
439
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 2013, 6520, 23422, 1012, 3231, 12324, 3231, 18382, 2013, 6520, 23422, 1012, 4563, 1012, 24471, 20974, 2229, 4747, 14028, 12324, 7901, 2465, 3231, 23393, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...